Skip to content

Commit a9287a9

Browse files
committed
improve commands-path example (cc #398)
1 parent e94a65f commit a9287a9

File tree

11 files changed

+168
-160
lines changed

11 files changed

+168
-160
lines changed

examples/command-paths/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cli
1+
docker

examples/command-paths/README.md

Lines changed: 65 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ This example was generated with:
1414
```bash
1515
$ bashly init
1616
$ bashly add settings
17-
# ... now edit src/settings.yml to match the example ...
17+
# ... now edit settings.yml to match the example ...
18+
# ... now edit src/bashly.yml to match the example ...
1819
$ bashly generate
1920
```
2021

@@ -25,57 +26,51 @@ $ bashly generate
2526
## `bashly.yml`
2627

2728
```yaml
28-
name: cli
29-
help: Sample application
29+
name: docker
30+
help: Docker example with nested command filenames
3031
version: 0.1.0
3132

32-
environment_variables:
33-
- name: api_key
34-
help: Set your API key
33+
flags:
34+
- long: --debug
35+
short: -d
36+
help: Enable debug mode
3537

3638
commands:
37-
- name: download
38-
alias: d
39-
help: Download a file
40-
41-
args:
42-
- name: source
43-
required: true
44-
help: URL to download from
45-
- name: target
46-
help: "Target filename (default: same as source)"
47-
48-
flags:
49-
- long: --force
50-
short: -f
51-
help: Overwrite existing files
52-
53-
examples:
54-
- cli download example.com
55-
- cli download example.com ./output -f
56-
57-
environment_variables:
58-
- name: default_target_location
59-
help: Set the default location to download to
60-
61-
- name: upload
62-
alias: u
63-
help: Upload a file
64-
args:
65-
- name: source
66-
required: true
67-
help: File to upload
39+
- name: container
40+
alias: c*
41+
help: Container commands
42+
43+
commands:
44+
- name: run
45+
help: Run a container
46+
args:
47+
- name: image
48+
help: Image name
49+
required: true
50+
51+
- name: stop
52+
help: Stop a container
53+
args:
54+
- name: container
55+
help: Container name
56+
required: true
57+
58+
- name: image
59+
alias: i*
60+
help: Image commands
61+
62+
commands:
63+
- name: ls
64+
alias: l
65+
help: Show all images
66+
67+
- name: ps
68+
help: List containers
6869

6970
flags:
70-
- long: --user
71-
short: -u
72-
arg: user
73-
help: Username to use for logging in
74-
required: true
75-
- long: --password
76-
short: -p
77-
arg: password
78-
help: Password to use for logging in
71+
- long: --all
72+
short: -a
73+
help: Show all containers
7974
```
8075
8176
## `settings.yml`
@@ -94,61 +89,58 @@ commands_dir: commands
9489

9590
## Generated script output
9691

97-
### `$ ./cli`
92+
### `$ ./docker`
9893

9994
```shell
100-
cli - Sample application
95+
docker - Docker example with nested command filenames
10196
10297
Usage:
103-
cli COMMAND
104-
cli [COMMAND] --help | -h
105-
cli --version | -v
98+
docker [OPTIONS] COMMAND
99+
docker [COMMAND] --help | -h
100+
docker --version | -v
106101
107102
Commands:
108-
download Download a file
109-
upload Upload a file
103+
container Container commands
104+
image Image commands
105+
ps List containers
110106
111107
112108
113109
```
114110

115-
### `$ ./cli -h`
111+
### `$ ./docker -h`
116112

117113
```shell
118-
cli - Sample application
114+
docker - Docker example with nested command filenames
119115
120116
Usage:
121-
cli COMMAND
122-
cli [COMMAND] --help | -h
123-
cli --version | -v
117+
docker [OPTIONS] COMMAND
118+
docker [COMMAND] --help | -h
119+
docker --version | -v
124120
125121
Commands:
126-
download Download a file
127-
upload Upload a file
122+
container Container commands
123+
image Image commands
124+
ps List containers
128125
129126
Options:
127+
--debug, -d
128+
Enable debug mode
129+
130130
--help, -h
131131
Show this help
132132
133133
--version, -v
134134
Show version number
135135
136-
Environment Variables:
137-
API_KEY
138-
Set your API key
139-
140136
141137
142138
```
143139

144-
### `$ ./cli download something`
140+
### `$ ./docker download something`
145141

146142
```shell
147-
# this file is located in 'src/commands/download.sh'
148-
# code for 'cli download' goes here
149-
# you can edit it freely and regenerate (it will not be overwritten)
150-
args:
151-
- ${args[source]} = something
143+
invalid command: download
152144
153145
154146
```
@@ -159,8 +151,9 @@ args:
159151
src/bashly.yml
160152
161153
src/commands:
162-
download.sh
163-
upload.sh
154+
container
155+
image
156+
ps.sh
164157
165158
166159
```
Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
1-
name: cli
2-
help: Sample application
1+
name: docker
2+
help: Docker example with nested command filenames
33
version: 0.1.0
44

5-
environment_variables:
6-
- name: api_key
7-
help: Set your API key
5+
flags:
6+
- long: --debug
7+
short: -d
8+
help: Enable debug mode
89

910
commands:
10-
- name: download
11-
alias: d
12-
help: Download a file
13-
14-
args:
15-
- name: source
16-
required: true
17-
help: URL to download from
18-
- name: target
19-
help: "Target filename (default: same as source)"
20-
21-
flags:
22-
- long: --force
23-
short: -f
24-
help: Overwrite existing files
25-
26-
examples:
27-
- cli download example.com
28-
- cli download example.com ./output -f
29-
30-
environment_variables:
31-
- name: default_target_location
32-
help: Set the default location to download to
33-
34-
- name: upload
35-
alias: u
36-
help: Upload a file
37-
args:
38-
- name: source
39-
required: true
40-
help: File to upload
11+
- name: container
12+
alias: c*
13+
help: Container commands
14+
15+
commands:
16+
- name: run
17+
help: Run a container
18+
args:
19+
- name: image
20+
help: Image name
21+
required: true
22+
23+
- name: stop
24+
help: Stop a container
25+
args:
26+
- name: container
27+
help: Container name
28+
required: true
29+
30+
- name: image
31+
alias: i*
32+
help: Image commands
33+
34+
commands:
35+
- name: ls
36+
alias: l
37+
help: Show all images
38+
39+
- name: ps
40+
help: List containers
4141

4242
flags:
43-
- long: --user
44-
short: -u
45-
arg: user
46-
help: Username to use for logging in
47-
required: true
48-
- long: --password
49-
short: -p
50-
arg: password
51-
help: Password to use for logging in
43+
- long: --all
44+
short: -a
45+
help: Show all containers
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
echo "# this file is located in 'src/commands/container/run.sh'"
2+
echo "# code for 'docker container run' goes here"
3+
echo "# you can edit it freely and regenerate (it will not be overwritten)"
4+
inspect_args
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
echo "# this file is located in 'src/commands/container/stop.sh'"
2+
echo "# code for 'docker container stop' goes here"
3+
echo "# you can edit it freely and regenerate (it will not be overwritten)"
4+
inspect_args

examples/command-paths/src/commands/download.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
echo "# this file is located in 'src/commands/image/ls.sh'"
2+
echo "# code for 'docker image ls' goes here"
3+
echo "# you can edit it freely and regenerate (it will not be overwritten)"
4+
inspect_args
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
echo "# this file is located in 'src/commands/ps.sh'"
2+
echo "# code for 'docker ps' goes here"
3+
echo "# you can edit it freely and regenerate (it will not be overwritten)"
4+
inspect_args

examples/command-paths/src/commands/upload.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/command-paths/test.sh

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

99
### Try Me ###
1010

11-
./cli
12-
./cli -h
13-
./cli download something
14-
ls -1 src/*
11+
./docker
12+
./docker -h
13+
./docker container run alpine
14+
ls -R src

0 commit comments

Comments
 (0)