Skip to content

Commit d4f42c5

Browse files
committed
update argfile example
1 parent 736ced8 commit d4f42c5

File tree

5 files changed

+79
-12
lines changed

5 files changed

+79
-12
lines changed

examples/argfile/.download

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1+
# Boolean flags in the argfile are loaded as defaults
12
--force
3+
4+
# Flag values must appear on the same line
25
--log "some path with spaces.log"
6+
7+
# Arguments in argfile also work for repeatable flags
8+
--header "x-from-file: 1"
9+
10+
# Unknown flags in the argfile are ignored
11+
--no-such-flag
12+
13+
# Non-flag lines in the argfile are ignored
14+
this line is ignored

examples/argfile/README.md

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,46 @@ flags:
3939
short: -l
4040
arg: path
4141
help: Path to log file
42+
43+
# Arguments in argfile also work for repeatable flags
44+
- long: --header
45+
short: -H
46+
arg: value
47+
repeatable: true
48+
help: Add an HTTP header
4249
````
4350

4451
## `.download`
4552

4653
````bash
54+
# Boolean flags in the argfile are loaded as defaults
4755
--force
56+
57+
# Flag values must appear on the same line
4858
--log "some path with spaces.log"
4959

50-
````
60+
# Arguments in argfile also work for repeatable flags
61+
--header "x-from-file: 1"
5162

52-
Only flag lines are loaded from the argfile. Each flag value must appear on the
53-
same line as the flag. Non-flag lines are ignored.
63+
# Unknown flags in the argfile are ignored
64+
--no-such-flag
65+
66+
# Non-flag lines in the argfile are ignored
67+
this line is ignored
68+
69+
````
5470

5571

5672
## Output
5773

74+
### `$ ./download --version`
75+
76+
````shell
77+
0.1.0
78+
79+
80+
````
81+
5882
### `$ ./download somesource`
5983

6084
````shell
@@ -64,24 +88,30 @@ same line as the flag. Non-flag lines are ignored.
6488
# Feel free to edit this file; your changes will persist when regenerating.
6589
args:
6690
- ${args[--force]} = 1
91+
- ${args[--header]} = x-from-file:\ 1
6792
- ${args[--log]} = some path with spaces.log
6893
- ${args[source]} = somesource
6994

7095

7196
````
7297

73-
### `$ ./download --help`
98+
### `$ ./download somesource --log cli.log`
7499

75100
````shell
76-
download - Sample application with autoloaded arguments
101+
# This file is located at 'src/root_command.sh'.
102+
# It contains the implementation for the 'download' command.
103+
# The code you write here will be wrapped by a function named 'root_command()'.
104+
# Feel free to edit this file; your changes will persist when regenerating.
105+
args:
106+
- ${args[--force]} = 1
107+
- ${args[--header]} = x-from-file:\ 1
108+
- ${args[--log]} = cli.log
109+
- ${args[source]} = somesource
110+
77111

78-
Usage:
79-
download SOURCE [OPTIONS]
80-
download --help | -h
81-
download --version | -v
82112
````
83113

84-
### `$ ./download somesource --log cli.log`
114+
### `$ ./download somesource --header "x-from-cli: 2"`
85115

86116
````shell
87117
# This file is located at 'src/root_command.sh'.
@@ -90,10 +120,12 @@ Usage:
90120
# Feel free to edit this file; your changes will persist when regenerating.
91121
args:
92122
- ${args[--force]} = 1
93-
- ${args[--log]} = cli.log
123+
- ${args[--header]} = x-from-file:\ 1 x-from-cli:\ 2
124+
- ${args[--log]} = some path with spaces.log
94125
- ${args[source]} = somesource
95126

96127

97128
````
98129

99130

131+

examples/argfile/src/bashly.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: download
22
help: Sample application with autoloaded arguments
33
version: 0.1.0
44

5-
# Allow users to configure args and flags in a file named '.download'
5+
# Allow users to configure flag defaults in a file named '.download'
66
argfile: .download
77

88
args:
@@ -18,3 +18,10 @@ flags:
1818
short: -l
1919
arg: path
2020
help: Path to log file
21+
22+
# Arguments in argfile also work for repeatable flags
23+
- long: --header
24+
short: -H
25+
arg: value
26+
repeatable: true
27+
help: Add an HTTP header

examples/argfile/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ bashly generate
88

99
### Try Me ###
1010

11+
./download --version
1112
./download somesource
1213
./download somesource --log cli.log
14+
./download somesource --header "x-from-cli: 2"

spec/approvals/examples/argfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ creating user files in src
33
skipped src/root_command.sh (exists)
44
created ./download
55
run ./download --help to test your bash script
6+
+ ./download --version
7+
0.1.0
68
+ ./download somesource
79
# This file is located at 'src/root_command.sh'.
810
# It contains the implementation for the 'download' command.
911
# The code you write here will be wrapped by a function named 'root_command()'.
1012
# Feel free to edit this file; your changes will persist when regenerating.
1113
args:
1214
- ${args[--force]} = 1
15+
- ${args[--header]} = x-from-file:\ 1
1316
- ${args[--log]} = some path with spaces.log
1417
- ${args[source]} = somesource
1518
+ ./download somesource --log cli.log
@@ -19,5 +22,16 @@ args:
1922
# Feel free to edit this file; your changes will persist when regenerating.
2023
args:
2124
- ${args[--force]} = 1
25+
- ${args[--header]} = x-from-file:\ 1
2226
- ${args[--log]} = cli.log
2327
- ${args[source]} = somesource
28+
+ ./download somesource --header 'x-from-cli: 2'
29+
# This file is located at 'src/root_command.sh'.
30+
# It contains the implementation for the 'download' command.
31+
# The code you write here will be wrapped by a function named 'root_command()'.
32+
# Feel free to edit this file; your changes will persist when regenerating.
33+
args:
34+
- ${args[--force]} = 1
35+
- ${args[--header]} = x-from-file:\ 1 x-from-cli:\ 2
36+
- ${args[--log]} = some path with spaces.log
37+
- ${args[source]} = somesource

0 commit comments

Comments
 (0)