diff --git a/cedar-policy-cli/CHANGELOG.md b/cedar-policy-cli/CHANGELOG.md index 82000bdf2..b0c2b1855 100644 --- a/cedar-policy-cli/CHANGELOG.md +++ b/cedar-policy-cli/CHANGELOG.md @@ -14,6 +14,7 @@ subcommands, while `-l` refers to `--principal`. Relatedly, the `--policies` long form of the flag is also now accepted across all subcommands. - The short form of `--template-linked` was changed from `-t` to `-k`. +- The `format` subcommand no longer takes a positional file argument. ## 2.4.2 diff --git a/cedar-policy-cli/src/lib.rs b/cedar-policy-cli/src/lib.rs index 346e9b93a..3f620e858 100644 --- a/cedar-policy-cli/src/lib.rs +++ b/cedar-policy-cli/src/lib.rs @@ -112,8 +112,8 @@ pub struct ValidateArgs { #[derive(Args, Debug)] pub struct CheckParseArgs { - /// File containing the policy set - #[clap(short, long = "policies", value_name = "FILE")] + /// Optional policy file name. If none is provided, read input from stdin. + #[arg(short, long = "policies", value_name = "FILE")] pub policies_file: Option, } @@ -310,8 +310,8 @@ pub struct LinkArgs { #[derive(Args, Debug)] pub struct FormatArgs { /// Optional policy file name. If none is provided, read input from stdin. - #[arg(value_name = "FILE")] - pub file_name: Option, + #[arg(short, long = "policies", value_name = "FILE")] + pub policy_file: Option, /// Custom line width (default: 80). #[arg(short, long, value_name = "UINT", default_value_t = 80)] @@ -519,7 +519,7 @@ pub fn link(args: &LinkArgs) -> CedarExitCode { } fn format_policies_inner(args: &FormatArgs) -> Result<()> { - let policies_str = read_from_file_or_stdin(args.file_name.as_ref(), "policy set")?; + let policies_str = read_from_file_or_stdin(args.policy_file.as_ref(), "policy set")?; let config = Config { line_width: args.line_width, indent_width: args.indent_width, diff --git a/cedar-policy-cli/tests/sample.rs b/cedar-policy-cli/tests/sample.rs index eca58b7ef..540a0c99f 100644 --- a/cedar-policy-cli/tests/sample.rs +++ b/cedar-policy-cli/tests/sample.rs @@ -111,6 +111,7 @@ fn run_format_test(policies_file: &str) { let format_cmd = assert_cmd::Command::cargo_bin("cedar") .expect("bin exists") .arg("format") + .arg("-p") .arg(policies_file) .assert(); assert_eq!(