Skip to content

Commit

Permalink
Do not require file arguments to use -- in CLI invocations (#389)
Browse files Browse the repository at this point in the history
* Do not require args to be last or use --

* Add test
  • Loading branch information
reese authored Dec 18, 2022
1 parent 9ed05fc commit f450950
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions script/tests/test_cli_interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,24 @@ DIFF
)
}

test_does_not_require_double_dash() {
(
cd "$(mktemp -d)"

cat > a_ruby_file_1.rb <<- DIFF
a 1,2,3
DIFF

f_rubyfmt -i a_ruby_file_1.rb

cat > expected.rb <<- DIFF
a(1, 2, 3)
DIFF

diff_files o expected.rb a_ruby_file_1.rb
)
}

test_format_respects_opt_out_header() {
(
cd "$(mktemp -d)"
Expand Down Expand Up @@ -662,6 +680,7 @@ test_format_directory_with_changes
test_format_input_file_with_changes
test_format_respects_opt_in_header
test_format_respects_opt_out_header
test_does_not_require_double_dash

test_format_without_changes
test_format_multiple_files_without_changes
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct CommandlineOpts {
/// - Directories (i.e. lib/foo/){n}
/// - Input files (i.e. @/tmp/files.txt). These files must contain one file path or directory per line
/// rubyfmt will use these as input.{n}
#[clap(name = "include-paths", last = true)]
#[clap(name = "include-paths")]
include_paths: Vec<String>,
}

Expand Down

0 comments on commit f450950

Please sign in to comment.