Skip to content

Commit 5bfebe4

Browse files
authored
Merge pull request #198 from DannyBen/remove/version-from-subcommand
Remove `--version` from subcommands
2 parents de4fa12 + 6886475 commit 5bfebe4

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

lib/bashly/views/command/fixed_flags_filter.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# :command.fixed_flag_filter
22
case "${1:-}" in
3+
% if root_command?
34
% if short_flag_exist? "-v"
45
--version )
56
% else
@@ -9,6 +10,7 @@ case "${1:-}" in
910
exit
1011
;;
1112

13+
% end
1214
% if short_flag_exist? "-h"
1315
--help )
1416
% else
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
+ bundle exec bashly generate
2+
creating user files in src
3+
created src/initialize.sh
4+
created src/git_command.sh
5+
created ./cli
6+
run ./cli --help to test your bash script
7+
+ ./cli --version
8+
1.2.3
9+
+ ./cli help
10+
cli - Sample application
11+
12+
Usage:
13+
cli [command]
14+
cli [command] --help | -h
15+
cli --version | -v
16+
17+
Commands:
18+
git Delegate to git
19+
20+
+ ./cli git --version
21+
# this file is located in 'src/git_command.sh'
22+
# code for 'cli git' goes here
23+
# you can edit it freely and regenerate (it will not be overwritten)
24+
args: none
25+
26+
other_args:
27+
- ${other_args[*]} = --version
28+
- ${other_args[0]} = --version
29+
+ ./cli git any 'other args' -or --flags
30+
# this file is located in 'src/git_command.sh'
31+
# code for 'cli git' goes here
32+
# you can edit it freely and regenerate (it will not be overwritten)
33+
args: none
34+
35+
other_args:
36+
- ${other_args[*]} = any other args -o -r --flags
37+
- ${other_args[0]} = any
38+
- ${other_args[1]} = other args
39+
- ${other_args[2]} = -o
40+
- ${other_args[3]} = -r
41+
- ${other_args[4]} = --flags
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/*.sh
2+
cli
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This fixture tests that somcommands do not handle the --version flag
2+
ref: https://github.com/DannyBen/bashly/discussions/197
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: cli
2+
help: Sample application
3+
version: 1.2.3
4+
5+
commands:
6+
- name: git
7+
help: Delegate to git
8+
catch_all: git_params
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
rm -f ./src/*.sh
4+
5+
set -x
6+
7+
bundle exec bashly generate
8+
9+
./cli --version
10+
./cli help
11+
./cli git --version
12+
./cli git any "other args" -or --flags

0 commit comments

Comments
 (0)