Skip to content

Commit 91ccdc6

Browse files
authored
Merge pull request #61 from DannyBen/change/flag-arg-eager-consumption
Change flag arguments (--flag ARG) to allow argument that starts with a dash
2 parents c26044b + 5676659 commit 91ccdc6

File tree

15 files changed

+230
-10
lines changed

15 files changed

+230
-10
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ FROM dannyben/alpine-ruby
33
ENV PS1 "\n\n>> bashly \W \$ "
44
WORKDIR /app
55

6-
RUN gem install bashly --version 0.4.0
6+
RUN gem install bashly --version 0.4.1rc1
77

88
ENTRYPOINT ["bashly"]

examples/commands/cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ cli_upload_parse_requirements() {
354354
case "$key" in
355355
# :flag.case
356356
--user | -u )
357-
if [[ $2 && $2 != -* ]]; then
357+
if [[ $2 ]]; then
358358
args[--user]="$2"
359359
shift
360360
shift
@@ -366,7 +366,7 @@ cli_upload_parse_requirements() {
366366

367367
# :flag.case
368368
--password | -p )
369-
if [[ $2 && $2 != -* ]]; then
369+
if [[ $2 ]]; then
370370
args[--password]="$2"
371371
shift
372372
shift

examples/custom-strings/download

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ parse_requirements() {
109109
case "$key" in
110110
# :flag.case
111111
--out | -o )
112-
if [[ $2 && $2 != -* ]]; then
112+
if [[ $2 ]]; then
113113
args[--out]="$2"
114114
shift
115115
shift

examples/default-values/convert

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ parse_requirements() {
107107
case "$key" in
108108
# :flag.case
109109
--format | -f )
110-
if [[ $2 && $2 != -* ]]; then
110+
if [[ $2 ]]; then
111111
args[--format]="$2"
112112
shift
113113
shift

examples/git-like/git

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ git_commit_parse_requirements() {
276276
case "$key" in
277277
# :flag.case
278278
--message | -m )
279-
if [[ $2 && $2 != -* ]]; then
279+
if [[ $2 ]]; then
280280
args[--message]="$2"
281281
shift
282282
shift

examples/minus-v/cli

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

102102
# :flag.case
103103
--host | -h )
104-
if [[ $2 && $2 != -* ]]; then
104+
if [[ $2 ]]; then
105105
args[--host]="$2"
106106
shift
107107
shift

examples/yaml/yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ parse_requirements() {
170170
case "$key" in
171171
# :flag.case
172172
--prefix | -p )
173-
if [[ $2 && $2 != -* ]]; then
173+
if [[ $2 ]]; then
174174
args[--prefix]="$2"
175175
shift
176176
shift

lib/bashly/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Bashly
2-
VERSION = "0.4.0"
2+
VERSION = "0.4.1rc1"
33
end

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 && $2 != -* ]]; then
4+
if [[ $2 ]]; then
55
args[<%= name %>]="$2"
66
shift
77
shift
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
+ bashly generate
2+
creating user files in src
3+
created src/initialize.sh
4+
created src/root_command.sh
5+
created ./argflag
6+
run ./argflag --help to test your bash script
7+
+ ./argflag -f -o
8+
--options requires an argument: --options, -o LIST
9+
+ ./argflag -o -f
10+
# this file is located in 'src/root_command.sh'
11+
# you can edit it freely and regenerate (it will not be overwritten)
12+
args:
13+
- ${args[--options]} = -f
14+
+ ./argflag -o '--verbose --anything' -f
15+
# this file is located in 'src/root_command.sh'
16+
# you can edit it freely and regenerate (it will not be overwritten)
17+
args:
18+
- ${args[--force]} = 1
19+
- ${args[--options]} = --verbose --anything

0 commit comments

Comments
 (0)