Skip to content

Commit 874424c

Browse files
committed
- [+] add more explain to CLI auto-generation, with showing the .yaml file
1 parent 3a36294 commit 874424c

2 files changed

Lines changed: 127 additions & 4 deletions

File tree

README.e.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,32 @@ Refer to
9898

9999
### Auto-generated Command line flag handling showcase using wireframe
100100

101+
First of all, this is what auto-generated help looks like:
102+
101103
#### $ {{exec "wireframe" | color "sh"}}
102104

103105
This gives full help at root level.
104106

107+
There are also two sub-commands, which are:
108+
105109
#### $ {{shell "wireframe put" | color "sh"}}
106110

107-
This gives sub-command `put` level help.
111+
The above gives sub-command `put` level help, and the next is for `get`:
108112

109113
#### $ {{shell "wireframe get" | color "sh"}}
110114

111-
This gives sub-command `get` level help.
115+
The above gives sub-command `get` level help.
116+
117+
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:
118+
119+
<a name="cli.yaml"/>
120+
121+
#### {{cat "wireframe_cli.yaml" | color "yaml"}}
122+
123+
124+
The above `yaml` definition is all it takes to get a wire-framed Go code to start with.
125+
126+
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:
112127

113128
#### $ wireframe put -i /tmp/f
114129

@@ -170,6 +185,8 @@ Copyright (C) 2018, Myself <me@mine.org>
170185

171186
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.
172187

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+
173190
## github-create-release - Create Release in Github
174191

175192
```

README.md

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
- [github-create-repo - Create Repository in Github](#github-create-repo---create-repository-in-github)
1414
- [gitlab-repo-create - Create Repository in Gitlab](#gitlab-repo-create---create-repository-in-gitlab)
1515
- [Data type def](#data-type-def)
16+
- [program name, name for the executable](#program-name-name-for-the-executable)
17+
- [NumOption: cli.AtLeast(1)](#numoption:-cliatleast(1))
18+
- [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")
1620

1721
## wireframe - wire-framing project for quick start
1822

@@ -103,6 +107,8 @@ Refer to
103107

104108
### Auto-generated Command line flag handling showcase using wireframe
105109

110+
First of all, this is what auto-generated help looks like:
111+
106112
#### $ wireframe
107113
```sh
108114
wire framing
@@ -133,6 +139,8 @@ Commands:
133139

134140
This gives full help at root level.
135141

142+
There are also two sub-commands, which are:
143+
136144
#### $ wireframe put
137145
```sh
138146
Upload into service
@@ -157,7 +165,7 @@ Options:
157165
-i, --input *The file to upload from (mandatory)
158166
```
159167

160-
This gives sub-command `put` level help.
168+
The above gives sub-command `put` level help, and the next is for `get`:
161169

162170
#### $ wireframe get
163171
```sh
@@ -184,7 +192,103 @@ Options:
184192
-o, --output The output file (default: some file)
185193
```
186194

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+
<a name="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:
188292

189293
#### $ wireframe put -i /tmp/f
190294

@@ -246,6 +350,8 @@ Copyright (C) 2018, Myself <me@mine.org>
246350

247351
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.
248352

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+
249355
## github-create-release - Create Release in Github
250356

251357
```

0 commit comments

Comments
 (0)