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

feat: require one of check or overwrite options in format command #51

Merged
merged 5 commits into from
Jan 16, 2025

Conversation

Scott8440
Copy link
Contributor

Requires that one of --overwrite or --check be provided and removes the default behavior of just printing the formatted files to stdout.

The --overwrite flag is now just a safety check so the caller knows that what they are doing is destructive, as writing the file is now "default" behavior, with --check being the modifier.

Test:

❯ cargo run --release format --check --overwrite ~/wdl/wdl-format/tests/format/optional_structs/
    Finished `release` profile [optimized] target(s) in 0.07s
     Running `target/release/sprocket format --check --overwrite /home/scott/wdl/wdl-format/tests/format/optional_structs/`
error: the argument '--check' cannot be used with '--overwrite'

Usage: sprocket format <--overwrite|--check> <PATH>

For more information, try '--help'.
❯ cargo run --release format ~/wdl/wdl-format/tests/format/optional_structs/ 
    Finished `release` profile [optimized] target(s) in 0.07s
     Running `target/release/sprocket format /home/scott/wdl/wdl-format/tests/format/optional_structs/`
error: the following required arguments were not provided:
  <--overwrite|--check>

Usage: sprocket format <--overwrite|--check> <PATH>

For more information, try '--help'.

@Scott8440 Scott8440 marked this pull request as draft January 10, 2025 03:23
@Scott8440 Scott8440 marked this pull request as ready for review January 10, 2025 03:30
src/commands/format.rs Outdated Show resolved Hide resolved
Copy link
Member

@a-frantz a-frantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits over word smithing. Please commit my suggestions and then run cargo +nightly fmt after.

src/commands/format.rs Outdated Show resolved Hide resolved
src/commands/format.rs Outdated Show resolved Hide resolved
src/commands/format.rs Outdated Show resolved Hide resolved
@a-frantz a-frantz merged commit 2a1fb1e into stjude-rust-labs:main Jan 16, 2025
8 checks passed
@claymcleod claymcleod mentioned this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants