Skip to content

Commit 4b40233

Browse files
committed
Allow empty string as flag argument
1 parent e8804a9 commit 4b40233

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

examples/commands/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ bashly generate
1717
./cli upload --help
1818
./cli upload sourcefile
1919
./cli upload sourcefile -u username
20+
./cli upload sourcefile -u username -p ''

lib/bashly/views/flag/case.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# :flag.case
22
<%= aliases.join " | " %> )
33
% if arg
4-
if [[ $2 ]]; then
4+
if [[ -n ${2+x} ]]; then
55
args[<%= name %>]="$2"
66
shift
77
shift

spec/approvals/examples/commands

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,11 @@ missing required flag: --user, -u USER
116116
args:
117117
- ${args[source]} = sourcefile
118118
- ${args[--user]} = username
119+
+ ./cli upload sourcefile -u username -p ''
120+
# this file is located in 'src/upload_command.sh'
121+
# code for 'cli upload' goes here
122+
# you can edit it freely and regenerate (it will not be overwritten)
123+
args:
124+
- ${args[--password]} =
125+
- ${args[source]} = sourcefile
126+
- ${args[--user]} = username

spec/fixtures/workspaces/flag-args-with-dash/argflag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ parse_requirements() {
142142

143143
# :flag.case
144144
--options | -o )
145-
if [[ $2 ]]; then
145+
if [[ -n ${2+x} ]]; then
146146
args[--options]="$2"
147147
shift
148148
shift

0 commit comments

Comments
 (0)