Skip to content

Commit 4d15e2b

Browse files
committed
fix shellcheck
1 parent cb05983 commit 4d15e2b

File tree

7 files changed

+113
-45
lines changed

7 files changed

+113
-45
lines changed

examples/command-default-force/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ args: none
9393
tester all - Run all tests
9494

9595
Usage:
96-
tester all
96+
tester [all]
9797
tester all --help | -h
9898

9999
Options:

examples/command-default/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,38 @@ args:
102102
- ${args[source]} = something
103103

104104

105+
````
106+
107+
### `$ ./ftp upload`
108+
109+
````shell
110+
missing required argument: SOURCE
111+
usage: ftp [upload] SOURCE
112+
113+
114+
````
115+
116+
### `$ ./ftp upload -h`
117+
118+
````shell
119+
ftp upload - Upload a file
120+
121+
Alias: u
122+
123+
Usage:
124+
ftp [upload] SOURCE
125+
ftp upload --help | -h
126+
127+
Options:
128+
--help, -h
129+
Show this help
130+
131+
Arguments:
132+
SOURCE
133+
File to upload
134+
135+
136+
105137
````
106138

107139
### `$ ./ftp upload something`

examples/conflicts/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ Usage:
5151
Options:
5252
--cache
5353
Enable cache
54+
Conflicts: --no-cache
5455

5556
--no-cache
5657
Disable cache
58+
Conflicts: --cache, --fast
5759

5860
--fast
5961
Run faster
62+
Conflicts: --no-cache
6063

6164
--help, -h
6265
Show this help

examples/needs/README.md

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,60 @@ $ bashly generate
1515
## `bashly.yml`
1616

1717
````yaml
18-
name: download
19-
help: Sample application to demonstrate the use of conflicting flags
18+
name: cli
19+
help: Sample application to demonstrate the use of needy flags
2020
version: 0.1.0
2121

2222
flags:
23-
- long: --cache
24-
help: Enable cache
25-
# Running --cache with --no-cache is not permitted
26-
conflicts: [--no-cache]
27-
- long: --no-cache
28-
help: Disable cache
29-
# Running --no-cache with --cache or with --fast is not permitted
30-
conflicts: [--cache, --fast]
31-
- long: --fast
32-
help: Run faster
33-
# Make sure to add the conflicting flags in both flags
34-
conflicts: [--no-cache]
23+
- long: --add
24+
short: -a
25+
arg: alias
26+
help: Alias to add
27+
# When using --add, --command and --target must also be provided
28+
needs: [--command, --target]
29+
30+
- long: --command
31+
short: -c
32+
arg: command
33+
help: Command for the alias
34+
# Note that this relationship is marked on both sides
35+
needs: [--add]
36+
37+
- long: --target
38+
short: -t
39+
arg: target
40+
help: Where to add the alias
41+
needs: [--add]
42+
allowed: [global, local]
3543
````
3644

3745

3846

3947
## Output
4048

41-
### `$ ./download -h`
49+
### `$ ./cli -h`
4250

4351
````shell
44-
download - Sample application to demonstrate the use of conflicting flags
52+
cli - Sample application to demonstrate the use of needy flags
4553

4654
Usage:
47-
download [OPTIONS]
48-
download --help | -h
49-
download --version | -v
55+
cli [OPTIONS]
56+
cli --help | -h
57+
cli --version | -v
5058

5159
Options:
52-
--cache
53-
Enable cache
60+
--add, -a ALIAS
61+
Alias to add
62+
Needs: --command, --target
5463

55-
--no-cache
56-
Disable cache
64+
--command, -c COMMAND
65+
Command for the alias
66+
Needs: --add
5767

58-
--fast
59-
Run faster
68+
--target, -t TARGET
69+
Where to add the alias
70+
Allowed: global, local
71+
Needs: --add
6072

6173
--help, -h
6274
Show this help
@@ -68,21 +80,31 @@ Options:
6880

6981
````
7082

71-
### `$ ./download --cache`
83+
### `$ ./cli --add deploy`
7284

7385
````shell
74-
# this file is located in 'src/root_command.sh'
75-
# you can edit it freely and regenerate (it will not be overwritten)
76-
args:
77-
- ${args[--cache]} = 1
86+
--add requires --command
87+
88+
89+
````
90+
91+
### `$ ./cli --add deploy --command 'git push'`
92+
93+
````shell
94+
--add requires --target
7895

7996

8097
````
8198

82-
### `$ ./download --no-cache --fast`
99+
### `$ ./cli --add deploy --command 'git push' --target local`
83100

84101
````shell
85-
conflicting options: --fast cannot be used with --no-cache
102+
# this file is located in 'src/root_command.sh'
103+
# you can edit it freely and regenerate (it will not be overwritten)
104+
args:
105+
- ${args[--add]} = deploy
106+
- ${args[--command]} = git push
107+
- ${args[--target]} = local
86108

87109

88110
````

examples/needs/src/bashly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cli
2-
help: Sample application to demonstrate the use of conflicting flags
2+
help: Sample application to demonstrate the use of needy flags
33
version: 0.1.0
44

55
flags:

examples/render-mandoc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ISSUE TRACKER
102102
AUTHORS
103103
Lana Lang.
104104

105-
Version 0.1.0 July 2024 download(1)
105+
Version 0.1.0 August 2024 download(1)
106106

107107

108108
````

lib/bashly/views/flag/needs.gtx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
= view_marker
1+
if needs
22

3-
> if [[ -n ${args['{{ name }}']+x} ]]; then
4-
> for need in {{ needs.join ' ' }}; do
5-
> if [[ -z "${args[$need]:-}" ]]; then
6-
> printf "%s\n" "{{ strings[:flag_requires_another] % { name: name, need: "$need" } }}" >&2
7-
> exit 1
8-
> fi
9-
> done
10-
> fi
11-
>
3+
= view_marker
4+
5+
if needs.count == 1
6+
> if [[ -n ${args['{{ name }}']+x} ]] && [[ -z "${args[{{ needs.first }}]:-}" ]]; then
7+
> printf "%s\n" "{{ strings[:flag_requires_another] % { name: name, need: needs.first } }}" >&2
8+
> exit 1
9+
> fi
10+
>
11+
else
12+
> if [[ -n ${args['{{ name }}']+x} ]]; then
13+
> for need in {{ needs.join ' ' }}; do
14+
> if [[ -z "${args[$need]:-}" ]]; then
15+
> printf "%s\n" "{{ strings[:flag_requires_another] % { name: name, need: "$need" } }}" >&2
16+
> exit 1
17+
> fi
18+
> done
19+
> fi
20+
>
21+
end
22+
end

0 commit comments

Comments
 (0)