casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
21.11k stars 467 forks source link

Add optional architecture attribution to receipt attribute annotations #1642

Open ptdecker opened 1 year ago

ptdecker commented 1 year ago

What are you trying to do? I would like to distinguish between macos on an arm architecture (M1 silicone) versus macos on an x86 via the receipt attributes

What's your proposed solution? Something like this:

[macos]
foo:
    echo "running on a mac and don't care about architecture"

[macos(arch(x86_64))]
bar:
    echo "running on a mac with x86_64 architecture"

[macos(arch(aarch64))]]
baz:
    echo "running on a mac with M1 architecture

Additional context The capability should be able to leverage the existing system information functions. If this can be done then any mix of operating system receipt attributes and system information functions could be used.

runeimp commented 1 year ago

I like the idea but for now you're better off figuring out how to script it using those functions. Something like the following is how I generally handle such things.

Justfile

os-arch := os() + "-" + arch()

@_default:
    just --list

# Recipe that calls hidden recipes
@recipe_name:
    echo "Recipe router"
    just _recipe_name-{{os-arch}}

# Hidden recipe
@_recipe_name-macos-aarch64:
    echo "Actual recipe for macOS on Apple Silicon"

# Hidden recipe
@_recipe_name-macos-x86_64:
    echo "Actual recipe for macOS on Intel"
$ just
Available recipes:
    recipe_name # Recipe that calls hidden recipes
$ just recipe_name
Recipe router
Actual recipe for macOS on Intel
ptdecker commented 1 year ago

Thank you for your rapid response, @runeimp . What you outline above will work "just" fine. Thank you for explaining this solution path. I will assume you want me to go ahead and close this request, but if you want to retain it for future feature consideration I assume also that you can re-open it for that purpose.

casey commented 1 year ago

I think this is a reasonable feature, so reopening.

JaydenElliott commented 10 months ago

would really like this feature also. Will give it a shot at implementing if no progress has been made on it.