Skip to content

Commit cb37eb8

Browse files
committed
- [*] update README, move cli auto-gen to wiki
1 parent 874424c commit cb37eb8

4 files changed

Lines changed: 26 additions & 347 deletions

File tree

README.e.md

Lines changed: 8 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ curl -H "Content-Type:application/json" https://gitlab.com/api/v3/projects?priva
6161

6262
## Data type def
6363

64+
<details>
65+
<summary>
66+
Data type def
67+
</summary>
68+
6469
```sh
6570
$ jsonfiddle j2s -f yaml -i wireframe_full.yaml --name WireframeT | sed '/Wireframe\b/d; s/ `yaml:.*$//' | gofmt | tee WireframeT.go
6671
package main
@@ -86,106 +91,16 @@ Wireframe:
8691
License: MIT
8792
```
8893

94+
</details>
95+
8996
The `jsonfiddle` is the JSON Fiddling tool that makes it easy to look at the JSON data from different aspects, which is [available here](https://github.com/go-jsonfile/jsonfiddle).
9097

9198
## Command line flag handling code auto-generation
9299

93100
Refer to
94101

95-
- [Command line flag handling code auto-generation](https://github.com/go-easygen/easygen#command-line-flag-handling-code-auto-generation), especially,
96-
- the [cli based command line flag handling code auto-generation](https://github.com/go-easygen/easygen#cli-based).
97-
- for the four different `UsageStyles` that can be used to control the `usage()` output, check out the [UsageStyle of package cli](https://github.com/go-easygen/wireframe/wiki/UsageStyle-of-package-cli) wiki.
98-
99-
### Auto-generated Command line flag handling showcase using wireframe
100-
101-
First of all, this is what auto-generated help looks like:
102-
103-
#### $ {{exec "wireframe" | color "sh"}}
104-
105-
This gives full help at root level.
106-
107-
There are also two sub-commands, which are:
108-
109-
#### $ {{shell "wireframe put" | color "sh"}}
110-
111-
The above gives sub-command `put` level help, and the next is for `get`:
112-
113-
#### $ {{shell "wireframe get" | color "sh"}}
114-
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:
127-
128-
#### $ wireframe put -i /tmp/f
129-
130-
131-
```sh
132-
$ touch /tmp/f; wireframe put -i /tmp/f
133-
[put]:
134-
&{Helper:{Help:false} Self:0xc420010240 Host:127.0.0.1 Port:8080 Daemonize:false Verbose:{value:0}}
135-
&{Filei:0xc4200d86c0}
136-
[]
137-
wireframe v 0.1.0. Upload into service
138-
Copyright (C) 2018, Myself <me@mine.org>
139-
```
140-
141-
This shows getting everything from the self-config file.
142-
Note the value of `Host`, it is read from the `wireframe_cfg.json` self-config file.
143-
144-
#### $ HOST=10.0.0.1 wireframe put -i /tmp/f
145-
```sh
146-
[put]:
147-
&{Helper:{Help:false} Self:0xc42008c1c0 Host:10.0.0.1 Port:8080 Daemonize:false Verbose:{value:0}}
148-
&{Filei:0xc4200f2660}
149-
[]
150-
wireframe v 0.1.0. Upload into service
151-
Copyright (C) 2018, Myself <me@mine.org>
152-
```
153-
154-
This shows overriding settings from the self-config file using the environment variables. Note the value of `Host` now is taken from the environment variable, instead from the `wireframe_cfg.json` self-config file.
155-
156-
#### $ HOST=10.0.0.1 wireframe put -i /tmp/f -H 168.0.0.1
157-
```sh
158-
[put]:
159-
&{Helper:{Help:false} Self:0xc4200901c0 Host:168.0.0.1 Port:8080 Daemonize:false Verbose:{value:0}}
160-
&{Filei:0xc4200f6680}
161-
[]
162-
wireframe v 0.1.0. Upload into service
163-
Copyright (C) 2018, Myself <me@mine.org>
164-
```
165-
166-
This shows overriding settings on the command line. Note the value of `Host` now is taken from the command line. So the priority of setting the `Host` value is, from higher priority to lower:
167-
168-
- command line
169-
- environment variable
170-
- self-config file
171-
172-
Three different levels.
173-
174-
#### $ wireframe get -o /tmp/f some more args
175-
176-
```sh
177-
$ HOST=10.0.0.1 wireframe get -o /tmp/f some more args
178-
[get]:
179-
&{Helper:{Help:false} Self:0xc420090180 Host:10.0.0.1 Port:8080 Daemonize:false Verbose:{value:0}}
180-
&{Fileo:0xc4200f8680}
181-
[some more args]
182-
wireframe v 0.1.0. Get from the service
183-
Copyright (C) 2018, Myself <me@mine.org>
184-
```
185-
186-
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.
102+
[Command line flag handling code auto-generation](https://github.com/go-easygen/wireframe/wiki/Command-line-flag-handling-code-auto-generation#auto-gen)
187103

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.
189104

190105
## github-create-release - Create Release in Github
191106

0 commit comments

Comments
 (0)