You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This just shows how to make use of the extra arguments passed from the command line. Note the setting is a bit different between `put` and `get` regarding what is mandatory on the command line. I.e., for `get`, there much be some extra command line arguments.
172
187
188
+
Basically, the above functionalities are what we can get out of the box from the above [single source of CLI definition file](#cli.yaml) automatically, without a single line of customization code.
189
+
173
190
## github-create-release - Create Release in Github
-[this (Self) means that root option is using the self-config .json file](#this-(self)-means-that-root-option-is-using-the-self-config-json-file)
19
+
-[UsageLead: "Usage:\\n wireframe [Options] dir [dirs...]"](#usagelead:-"usage:\\n--wireframe-options-dir-dirs")
16
20
17
21
## wireframe - wire-framing project for quick start
18
22
@@ -103,6 +107,8 @@ Refer to
103
107
104
108
### Auto-generated Command line flag handling showcase using wireframe
105
109
110
+
First of all, this is what auto-generated help looks like:
111
+
106
112
#### $ wireframe
107
113
```sh
108
114
wire framing
@@ -133,6 +139,8 @@ Commands:
133
139
134
140
This gives full help at root level.
135
141
142
+
There are also two sub-commands, which are:
143
+
136
144
#### $ wireframe put
137
145
```sh
138
146
Upload into service
@@ -157,7 +165,7 @@ Options:
157
165
-i, --input *The file to upload from (mandatory)
158
166
```
159
167
160
-
This gives sub-command `put` level help.
168
+
The above gives sub-command `put` level help, and the next is for `get`:
161
169
162
170
#### $ wireframe get
163
171
```sh
@@ -184,7 +192,103 @@ Options:
184
192
-o, --output The output file (default: some file)
185
193
```
186
194
187
-
This gives sub-command `get` level help.
195
+
The above gives sub-command `get` level help.
196
+
197
+
Before we see how it runs, let's take a look at how to define and get all the above. Here is the single source of CLI definition for all above:
198
+
199
+
<aname="cli.yaml"/>
200
+
201
+
#### wireframe_cli.yaml
202
+
```yaml
203
+
# program name, name for the executable
204
+
ProgramName: wireframe
205
+
Authors: Myself <me@mine.org>
206
+
207
+
PackageName: main
208
+
209
+
Name: wireframe
210
+
Desc: "wire framing"
211
+
Text: Tool to showcase wire-framing command line app fast prototype
212
+
#NumOption: cli.AtLeast(1)
213
+
Style: cli.DenseNormalStyle
214
+
NumArg: cli.AtLeast(1)
215
+
Global: true
216
+
# this (Self) means that root option is using the self-config .json file
217
+
Self: true
218
+
219
+
#UsageLead: "Usage:\\n wireframe [Options] dir [dirs...]"
220
+
221
+
Options:
222
+
- Name: Self
223
+
Type: '*rootT'
224
+
Flag: c,config
225
+
Usage: config file\n
226
+
#Value: "$__EXEC_FILENAME.json"
227
+
Value: wireframe_cfg.json
228
+
229
+
- Name: Host
230
+
Type: string
231
+
Flag: H,host
232
+
Usage: host addr
233
+
Value: '$HOST'
234
+
235
+
- Name: Port
236
+
Type: int
237
+
Flag: p,port
238
+
Usage: listening port\n
239
+
240
+
- Name: Demo
241
+
Type: string
242
+
Flag: long
243
+
Usage: Now can use the \\n to arrange parameters in groups\n\t\t\tJust like what is showing here, even with extreme long usage text that can spread across multiple lines\n
244
+
Value: '$Demo'
245
+
246
+
- Name: Daemonize
247
+
Type: bool
248
+
Flag: D,daemonize
249
+
Usage: daemonize the service
250
+
251
+
- Name: Verbose
252
+
Type: cli.Counter
253
+
Flag: v,verbose
254
+
Usage: Verbose mode (Multiple -v options increase the verbosity)\n
255
+
256
+
Command:
257
+
258
+
- Name: put
259
+
Desc: "Upload into service"
260
+
Text: 'Usage:\n wireframe put -i /tmp/f'
261
+
#NumArg: cli.AtLeast(1)
262
+
NumOption: cli.AtLeast(1)
263
+
264
+
Options:
265
+
- Name: Filei
266
+
Type: '*clix.Reader'
267
+
Flag: '*i,input'
268
+
Usage: The file to upload from (mandatory)
269
+
270
+
- Name: get
271
+
Desc: Get from the service
272
+
Text: 'Usage:\n wireframe get -o /tmp/f mandatory some more args'
273
+
NumArg: cli.AtLeast(1)
274
+
#NumOption: cli.AtLeast(1)
275
+
276
+
Options:
277
+
- Name: Filei
278
+
Type: '*clix.Reader'
279
+
Flag: '*i,input'
280
+
Usage: The file to upload from (mandatory)
281
+
282
+
- Name: Fileo
283
+
Type: '*clix.Writer'
284
+
Flag: o,output
285
+
Usage: 'The output file (default: some file)'
286
+
```
287
+
288
+
289
+
The above `yaml` definition is all it takes to get a wire-framed Go code to start with.
290
+
291
+
We don't need to jump into the generate code itself now, just take a look what we will get out of the box first:
This just shows how to make use of the extra arguments passed from the command line. Note the setting is a bit different between `put` and `get` regarding what is mandatory on the command line. I.e., for `get`, there much be some extra command line arguments.
248
352
353
+
Basically, the above functionalities are what we can get out of the box from the above [single source of CLI definition file](#cli.yaml) automatically, without a single line of customization code.
354
+
249
355
## github-create-release - Create Release in Github
0 commit comments