File tree Expand file tree Collapse file tree 7 files changed +105
-4
lines changed
fixtures/workspaces/global-flags Expand file tree Collapse file tree 7 files changed +105
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ source 'https://rubygems.org'
22
33gem 'byebug'
44gem 'lp'
5- gem 'rentacop'
65gem 'rspec'
76gem 'rspec_approvals'
87gem 'runfile'
Original file line number Diff line number Diff line change 11= view_marker
22
3- > case "${1:-}" in
3+ > while [[ $# -gt 0 ]]; do
4+ > case "${1:-}" in
45
56if root_command?
67 = short_flag_exist?("-v") ? "--version )" : "--version | -v )"
1920
2021if global_flags?
2122 flags.each do |flag|
22- = flag.render(:case)
23+ = flag.render(:case).indent(2)
2324 end
2425end
2526
26- > esac
27+ > * )
28+ > break
29+ > ;;
30+ >
31+ > esac
32+ > done
2733>
Original file line number Diff line number Diff line change 1+ + bundle exec bashly generate
2+ creating user files in src
3+ created src/initialize.sh
4+ created src/show_command.sh
5+ created ./flags
6+ run ./flags --help to test your bash script
7+ + ./flags -h
8+ flags - Verifies multiple global flags work as expected
9+
10+ Usage:
11+ flags [OPTIONS] COMMAND
12+ flags [COMMAND] --help | -h
13+ flags --version | -v
14+
15+ Commands:
16+ show
17+
18+ Options:
19+ --help, -h
20+ Show this help
21+
22+ --version, -v
23+ Show version number
24+
25+ --alpha, -a
26+ Alpha
27+
28+ --bravo, -b
29+ Bravo
30+
31+ --charlie, -c NAME (required)
32+ Charlie
33+ Allowed: chaplin
34+
35+ + ./flags show
36+ missing required flag: --charlie, -c NAME
37+ + ./flags -c clark show
38+ --charlie must be one of: chaplin
39+ + ./flags -c chaplin show
40+ # this file is located in 'src/show_command.sh'
41+ # code for 'flags show' goes here
42+ # you can edit it freely and regenerate (it will not be overwritten)
43+ args:
44+ - ${args[--charlie]} = chaplin
45+ + ./flags -c chaplin -ab show
46+ # this file is located in 'src/show_command.sh'
47+ # code for 'flags show' goes here
48+ # you can edit it freely and regenerate (it will not be overwritten)
49+ args:
50+ - ${args[--alpha]} = 1
51+ - ${args[--bravo]} = 1
52+ - ${args[--charlie]} = chaplin
Original file line number Diff line number Diff line change 1+ flags
2+ src /* .sh
Original file line number Diff line number Diff line change 1+ This fixture tests the global flags feature, and specifically, that it works
2+ with multiple flags.
3+
4+ Reference issue: https://github.com/DannyBen/bashly/issues/293
Original file line number Diff line number Diff line change 1+ name : flags
2+ help : Verifies multiple global flags work as expected
3+ version : 0.1.0
4+
5+ flags :
6+ - long : --alpha
7+ short : -a
8+ help : Alpha
9+ - long : --bravo
10+ short : -b
11+ help : Bravo
12+ - long : --charlie
13+ short : -c
14+ help : Charlie
15+ arg : name
16+ required : true
17+ allowed : [chaplin]
18+
19+ commands :
20+ - name : show
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # This fixture tests the global flags feature, and specifically, that it works
4+ # with multiple flags.
5+ # Reference issue: https://github.com/DannyBen/bashly/issues/293
6+
7+ rm -f ./src/* .sh
8+ rm -f ./flags
9+
10+ set -x
11+
12+ bundle exec bashly generate
13+
14+ ./flags -h
15+ ./flags show
16+ ./flags -c clark show
17+ ./flags -c chaplin show
18+ ./flags -c chaplin -ab show
You can’t perform that action at this time.
0 commit comments