11# Argfile Example
22
3- Demonstrates how to autoload additional arguments from a file using the
4- ` argfile ` command option.
3+ Demonstrates how to autoload flag defaults from a file using the ` argfile `
4+ command option.
55
66This example was generated with:
77
@@ -23,7 +23,7 @@ name: download
2323help : Sample application with autoloaded arguments
2424version : 0.1.0
2525
26- # Allow users to configure args and flags in a file named '.download'
26+ # Allow users to configure flag defaults in a file named '.download'
2727argfile : .download
2828
2929args :
@@ -39,19 +39,47 @@ flags:
3939 short : -l
4040 arg : path
4141 help : Path to log file
42+
43+ # Arguments in argfile also work for repeatable and unique flags
44+ - long : --header
45+ short : -H
46+ arg : value
47+ repeatable : true
48+ unique : true
49+ help : Add an HTTP header
4250` ` ` `
4351
4452# # `.download`
4553
4654` ` ` ` bash
55+ # Boolean flags in the argfile are loaded as defaults
4756--force
57+
58+ # Flag values must appear on the same line
4859--log "some path with spaces.log"
4960
61+ # Arguments in argfile also work for repeatable flags
62+ --header "x-from-file : 1"
63+
64+ # Unknown flags in the argfile are ignored
65+ --no-such-flag
66+
67+ # Non-flag lines in the argfile are ignored
68+ this line is ignored
69+
5070````
5171
5272
5373## Output
5474
75+ ### ` $ ./download --version `
76+
77+ ```` shell
78+ 0.1.0
79+
80+
81+ ````
82+
5583### ` $ ./download somesource `
5684
5785```` shell
6189# Feel free to edit this file; your changes will persist when regenerating.
6290args:
6391- ${args[--force]} = 1
92+ - ${args[--header]} = x-from-file:\ 1
6493- ${args[--log]} = some path with spaces.log
6594- ${args[source]} = somesource
6695
@@ -76,11 +105,44 @@ args:
76105# Feel free to edit this file; your changes will persist when regenerating.
77106args:
78107- ${args[--force]} = 1
108+ - ${args[--header]} = x-from-file:\ 1
79109- ${args[--log]} = cli.log
80110- ${args[source]} = somesource
81111
82112
83113````
84114
115+ ### ` $ ./download somesource --header "x-from-cli: 2" `
116+
117+ ```` shell
118+ # This file is located at 'src/root_command.sh'.
119+ # It contains the implementation for the 'download' command.
120+ # The code you write here will be wrapped by a function named 'root_command()'.
121+ # Feel free to edit this file; your changes will persist when regenerating.
122+ args:
123+ - ${args[--force]} = 1
124+ - ${args[--header]} = x-from-file:\ 1 x-from-cli:\ 2
125+ - ${args[--log]} = some path with spaces.log
126+ - ${args[source]} = somesource
127+
128+
129+ ````
130+
131+ ### ` $ ./download somesource --header "x-from-file: 1" `
132+
133+ ```` shell
134+ # This file is located at 'src/root_command.sh'.
135+ # It contains the implementation for the 'download' command.
136+ # The code you write here will be wrapped by a function named 'root_command()'.
137+ # Feel free to edit this file; your changes will persist when regenerating.
138+ args:
139+ - ${args[--force]} = 1
140+ - ${args[--header]} = x-from-file:\ 1
141+ - ${args[--log]} = some path with spaces.log
142+ - ${args[source]} = somesource
143+
144+
145+ ````
146+
85147
86148
0 commit comments