Skip to content

Commit

Permalink
Merge pull request #500 from DannyBen/update/hyphen-arg-test
Browse files Browse the repository at this point in the history
Update flag-args-with-dash test to validate #499
  • Loading branch information
DannyBen authored Mar 1, 2024
2 parents c7f7e80 + c8b4208 commit faf9216
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
16 changes: 16 additions & 0 deletions spec/approvals/fixtures/flag-args-with-dash
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ args:
args:
- ${args[--force]} = 1
- ${args[--options]} = --verbose --anything
+ BASHLY_COMPACT_SHORT_FLAGS=no
+ bundle exec bashly generate
creating user files in src
skipped src/root_command.sh (exists)
created ./argflag
run ./argflag --help to test your bash script
+ ./argflag -o -force
# this file is located in 'src/root_command.sh'
# you can edit it freely and regenerate (it will not be overwritten)
args:
- ${args[--options]} = -force
+ ./argflag -o '-f -o'
# this file is located in 'src/root_command.sh'
# you can edit it freely and regenerate (it will not be overwritten)
args:
- ${args[--options]} = -f -o
12 changes: 11 additions & 1 deletion spec/fixtures/workspaces/flag-args-with-dash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@ starts with a dash - for example:
--options '--verbose -v'
```

Reference issue: https://github.com/DannyBen/bashly/issues/58
Note that when it is expected that flag arguments will be in a form that
resembles a collection of short flags (i.e. single hyphen followed by
alphanumeric characters), for example `--options -abc`, then the compact flags
feature should be disabled with `compact_short_flags: false` in the settings.

See https://bashly.dannyb.co/usage/settings/#compact_short_flags

Reference issues:

- https://github.com/DannyBen/bashly/issues/58
- https://github.com/DannyBen/bashly/issues/499
11 changes: 7 additions & 4 deletions spec/fixtures/workspaces/flag-args-with-dash/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env bash

# This fixture tests that alias command codes work properly
# It is executed as part of the Runfile examples test
# Reference issue: https://github.com/DannyBen/bashly/issues/16

rm -f ./src/*.sh
rm -f ./argflag

Expand All @@ -14,3 +10,10 @@ bundle exec bashly generate
./argflag -f -o
./argflag -o -f
./argflag -o '--verbose --anything' -f

# if flag args are expected to look like a short flag collection, it is
# necessary to disable `compact_short_flags` either in settings or environment
# variable.
BASHLY_COMPACT_SHORT_FLAGS=no bundle exec bashly generate
./argflag -o -force
./argflag -o '-f -o'

0 comments on commit faf9216

Please sign in to comment.