Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-line commands #837

Open
emilk opened this issue Feb 23, 2024 · 2 comments
Open

Multi-line commands #837

emilk opened this issue Feb 23, 2024 · 2 comments
Labels
💣 breaking Breaks something in the api or config ✨ enhancement Feature request 👋 good first issue Good for newcomers

Comments

@emilk
Copy link

emilk commented Feb 23, 2024

Problem description

I want to get rid of our justfile and replace it with pixi commands. One thing preventing this is the lack of multiline commands.

Consider this justfile script:

rs-lint:
    cargo cranky --quiet --all-features -- --deny warnings
    typos
    scripts/lint.py
    cargo doc --quiet --no-deps --all-features
    cargo doc --quiet --document-private-items --no-deps --all-features
    cargo test --quiet --doc --all-features # runs all doc-tests

If I want to translate it into pixi.toml it will turn into something like:

rs-lint: """
       cargo cranky --quiet --all-features -- --deny warnings
    && typos
    && cargo doc --quiet --no-deps --all-features
    && cargo doc --quiet --document-private-items --no-deps --all-features
    && cargo test --quiet --doc --all-features # runs all doc-tests
    && scripts/lint.py
"""

This is okay, but has several shortcomings:

A) its syntax is somewhat ugly
B) it still execute as one big blob
C) it is not obvious to the reader that any extra argument to the script is piped to scripts/lint.py in this case

Proposal

I suggest that each new line is considered its own command, with an implicit && between them:

rs-lint: """
    cargo cranky --quiet --all-features -- --deny warnings
    typos
    cargo doc --quiet --no-deps --all-features
    cargo doc --quiet --document-private-items --no-deps --all-features
    cargo test --quiet --doc --all-features # runs all doc-tests
    scripts/lint.py
"""

Pixi will execute each command in order, and at any failure it would abort (like set -e in bash).
Moreover, pixi would print each command before executing it (like set -x in bash).
So the output of could be somethng like:

$ pixi run rs-lint
+ cargo cranky --quiet --all-features -- --deny warnings
+ typos
+ cargo doc --quiet --no-deps --all-features
`src/lib.rs:52`: Error: broken doclink `Foo`
$

Furthermore, I would suggest that the implicit "pass extra arguments to the command" feature would NOT be applied in the multi-command mode.

@tdejager
Copy link
Contributor

tdejager commented Mar 4, 2024

Would it make sense to use a toml array instead? Like the behavior would be less implicit, but somewhat more cumbersome to write.

EDIT: I meant the trade-off being that the behavior...

@emilk
Copy link
Author

emilk commented Mar 8, 2024

I would like an array, but I believe that would be a breaking change as I believe this already works:

rs-lint = ["cargo", "clippy", "-p", "my_crate"]

(though I'm not sure how used or useful that syntax is, as it is very verbose)

@ruben-arts ruben-arts added the 💣 breaking Breaks something in the api or config label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💣 breaking Breaks something in the api or config ✨ enhancement Feature request 👋 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants