bashly 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -4
- data/lib/bashly/cli.rb +1 -0
- data/lib/bashly/commands/doc.rb +90 -0
- data/lib/bashly/docs/arg.yml +94 -0
- data/lib/bashly/docs/command.yml +310 -0
- data/lib/bashly/docs/env.yml +54 -0
- data/lib/bashly/docs/flag.yml +163 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/command_fallback.gtx +2 -0
- data/lib/bashly/views/command/default_assignments.gtx +2 -2
- data/lib/bashly/views/command/fixed_flags_filter.gtx +2 -2
- data/lib/bashly/views/command/parse_requirements_case_catch_all.gtx +2 -2
- data/lib/bashly/views/command/parse_requirements_case_repeatable.gtx +5 -6
- data/lib/bashly/views/command/parse_requirements_case_simple.gtx +2 -2
- data/lib/bashly/views/command/parse_requirements_while.gtx +9 -1
- data/lib/bashly/views/command/required_args_filter.gtx +1 -1
- data/lib/bashly/views/command/required_flags_filter.gtx +1 -1
- data/lib/bashly/views/command/run.gtx +1 -1
- data/lib/bashly/views/command/whitelist_filter.gtx +2 -2
- data/lib/bashly/views/flag/case_arg.gtx +4 -4
- data/lib/bashly/views/flag/case_no_arg.gtx +2 -2
- data/lib/bashly/views/flag/conflicts.gtx +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 310bcfcf9a37601cdf37bd37f81c96fc8e33e4e38e601a4d496a2b8fed20e319
|
4
|
+
data.tar.gz: 72c4644b4051c9a290192c4d497bdcb80c8bdc5d473fe3c7bb01c40209f62a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b655051b58edb3182e022405484e006ef1ac6a7a0815fe6be77f38cbe57a5f9bf90adfa45be713719d718221451f9ab88087e4253fb7356651ff03f7ddc5b61
|
7
|
+
data.tar.gz: 992d1f15fdb7649375b2c1f8f09054b73dc7aef92c7e980995b7fd4c28671b42c9635078617ff10bba81a49836852b53151ef5559b53a55cf7070197a5937a01
|
data/README.md
CHANGED
@@ -27,7 +27,6 @@ usually handled by a framework in any other programming language.
|
|
27
27
|
It is available both as a [ruby gem](https://rubygems.org/gems/bashly) and as
|
28
28
|
a [docker image](https://hub.docker.com/r/dannyben/bashly).
|
29
29
|
|
30
|
-
|
31
30
|
## Documentation
|
32
31
|
|
33
32
|
- [Bashly Homepage][docs]
|
@@ -49,6 +48,7 @@ a [docker image](https://hub.docker.com/r/dannyben/bashly).
|
|
49
48
|
Bashly is responsible for:
|
50
49
|
|
51
50
|
- Generating a **single, standalone bash script**.
|
51
|
+
- Generating a **human readable, shellcheck-compliant and shfmt-compliant script**.
|
52
52
|
- Generating **usage texts** and help screens, showing your tool's arguments, flags and commands (works for sub-commands also).
|
53
53
|
- Parsing the user's command line and extracting:
|
54
54
|
- Optional or required **positional arguments**.
|
@@ -72,15 +72,12 @@ to contribute, feel free to [open an issue][issues] or
|
|
72
72
|
|
73
73
|
Visit the *[How to contribute][contributing]* page for more information.
|
74
74
|
|
75
|
-
|
76
75
|
## Stargazers and Forkers
|
77
76
|
|
78
77
|
[](https://github.com/DannyBen/bashly/stargazers)
|
79
78
|
|
80
79
|
[](https://github.com/DannyBen/bashly/network/members)
|
81
80
|
|
82
|
-
|
83
|
-
|
84
81
|
[issues]: https://github.com/DannyBen/bashly/issues
|
85
82
|
[discussions]: https://github.com/DannyBen/bashly/discussions
|
86
83
|
[docs]: https://bashly.dannyb.co/
|
data/lib/bashly/cli.rb
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
module Bashly
|
2
|
+
module Commands
|
3
|
+
class Doc < Base
|
4
|
+
summary 'Show bashly reference documentation'
|
5
|
+
help 'This command displays bite-sized help for all the bashly configuration options in the terminal.'
|
6
|
+
|
7
|
+
usage 'bashly doc [SEARCH] [--index]'
|
8
|
+
usage 'bashly doc (-h|--help)'
|
9
|
+
|
10
|
+
option '-i --index', 'Show option keys only'
|
11
|
+
param 'SEARCH', 'Search for options that match this text'
|
12
|
+
|
13
|
+
example 'bashly doc command'
|
14
|
+
example 'bashly doc command.flags'
|
15
|
+
example 'bashly doc flag. -i'
|
16
|
+
example 'bashly doc catch_all'
|
17
|
+
|
18
|
+
def run
|
19
|
+
if args['--index']
|
20
|
+
puts data.keys
|
21
|
+
else
|
22
|
+
show
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def show
|
29
|
+
data.each do |key, info|
|
30
|
+
show_key key
|
31
|
+
show_help info['help']
|
32
|
+
show_example info['example'] if info['example']
|
33
|
+
show_url info['url'] if info['url']
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def show_key(key)
|
38
|
+
say "!txtgrn!#{key}"
|
39
|
+
say ''
|
40
|
+
end
|
41
|
+
|
42
|
+
def show_url(url)
|
43
|
+
say " See !undblu!#{url}"
|
44
|
+
say ''
|
45
|
+
end
|
46
|
+
|
47
|
+
def show_example(example)
|
48
|
+
example = word_wrap " #{example}"
|
49
|
+
example.gsub!(/^(\s*- )?(\s*\w+):/, '\1!txtblu!\2!txtrst!:')
|
50
|
+
example.gsub!(/^(\s*- )/, '!txtylw!\1!txtrst!')
|
51
|
+
example.gsub!(/^(\s*#.+)/, '!txtpur!\1!txtrst!')
|
52
|
+
say example
|
53
|
+
say ''
|
54
|
+
end
|
55
|
+
|
56
|
+
def show_help(help)
|
57
|
+
help = word_wrap " #{help}"
|
58
|
+
help.gsub!(/`([^`]+)`/, '!txtgrn!\1!txtrst!')
|
59
|
+
say help
|
60
|
+
say ''
|
61
|
+
end
|
62
|
+
|
63
|
+
def data
|
64
|
+
return raw_data unless args['SEARCH']
|
65
|
+
|
66
|
+
result = raw_data.select { |k, _v| k.== args['SEARCH'] }
|
67
|
+
return result if result.any?
|
68
|
+
|
69
|
+
result = raw_data.select { |k, _v| k.include? args['SEARCH'] }
|
70
|
+
return result if result.any?
|
71
|
+
|
72
|
+
raise Error, "No match"
|
73
|
+
end
|
74
|
+
|
75
|
+
def raw_data
|
76
|
+
@raw_data ||= begin
|
77
|
+
result = {}
|
78
|
+
Dir["#{docs_dir}/*.yml"].sort.each do |path|
|
79
|
+
result.merge! YAML.load_file(path)
|
80
|
+
end
|
81
|
+
result
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def docs_dir
|
86
|
+
@docs_dir ||= File.expand_path '../docs', __dir__
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
arg:
|
2
|
+
help: Define positional arguments.
|
3
|
+
url: https://bashly.dannyb.co/configuration/argument/
|
4
|
+
example: |-
|
5
|
+
args:
|
6
|
+
- name: user
|
7
|
+
help: AWS Username.
|
8
|
+
required: true
|
9
|
+
|
10
|
+
- name: role
|
11
|
+
help: User role.
|
12
|
+
default: admin
|
13
|
+
allowed:
|
14
|
+
- admin
|
15
|
+
- guest
|
16
|
+
|
17
|
+
arg.allowed:
|
18
|
+
help: Specify a list of allowed values. Can be used in conjunction with `default` and `required`.
|
19
|
+
url: https://bashly.dannyb.co/configuration/argument/#allowed
|
20
|
+
example: |-
|
21
|
+
args:
|
22
|
+
- name: region
|
23
|
+
help: Region to connect to
|
24
|
+
|
25
|
+
# allowed + required
|
26
|
+
allowed: [eu, us]
|
27
|
+
required: true
|
28
|
+
|
29
|
+
- name: environment
|
30
|
+
help: Environment to connect to
|
31
|
+
|
32
|
+
# allowed + default
|
33
|
+
allowed: [stage, production, development]
|
34
|
+
default: development
|
35
|
+
|
36
|
+
arg.default:
|
37
|
+
help: Specify the value to apply when not provided by the user.
|
38
|
+
url: https://bashly.dannyb.co/configuration/argument/#default
|
39
|
+
example: |-
|
40
|
+
args:
|
41
|
+
- name: images
|
42
|
+
help: Image files to convert.
|
43
|
+
default: "*.jpg"
|
44
|
+
|
45
|
+
arg.help:
|
46
|
+
help: Specify the help message for this argument.
|
47
|
+
url: https://bashly.dannyb.co/configuration/argument/#help
|
48
|
+
example: |-
|
49
|
+
args:
|
50
|
+
- name: user
|
51
|
+
help: AWS Username.
|
52
|
+
required: true
|
53
|
+
|
54
|
+
arg.name:
|
55
|
+
help: Specify the lowercase name of the argument.
|
56
|
+
url: https://bashly.dannyb.co/configuration/argument/#name
|
57
|
+
example: |-
|
58
|
+
args:
|
59
|
+
- name: user
|
60
|
+
help: AWS Username.
|
61
|
+
required: true
|
62
|
+
|
63
|
+
arg.repeatable:
|
64
|
+
help: |-
|
65
|
+
Specify that this argument can be provided multiple times.
|
66
|
+
|
67
|
+
The argument below will be received as a space-delimited string which needs to be converted to an array with:
|
68
|
+
`eval "data=(${args[file]})"`
|
69
|
+
|
70
|
+
url: https://bashly.dannyb.co/configuration/argument/#repeatable
|
71
|
+
example: |-
|
72
|
+
args:
|
73
|
+
- name: file
|
74
|
+
help: One or more files to process
|
75
|
+
required: true
|
76
|
+
repeatable: true
|
77
|
+
|
78
|
+
arg.required:
|
79
|
+
help: Specify that this argument is required.
|
80
|
+
url: https://bashly.dannyb.co/configuration/argument/#required
|
81
|
+
example: |-
|
82
|
+
args:
|
83
|
+
- name: region
|
84
|
+
help: Region to connect to
|
85
|
+
required: true
|
86
|
+
|
87
|
+
arg.validate:
|
88
|
+
help: Apply custom validation functions.
|
89
|
+
|
90
|
+
url: https://bashly.dannyb.co/configuration/argument/#validate
|
91
|
+
example: |-
|
92
|
+
args:
|
93
|
+
- name: path
|
94
|
+
validate: file_exists
|
@@ -0,0 +1,310 @@
|
|
1
|
+
command:
|
2
|
+
help: Define the root command, or any sub-command.
|
3
|
+
url: https://bashly.dannyb.co/configuration/command/
|
4
|
+
example: |-
|
5
|
+
name: rush
|
6
|
+
help: Personal package manager
|
7
|
+
version: 0.6.5
|
8
|
+
|
9
|
+
commands:
|
10
|
+
- name: add
|
11
|
+
alias: a
|
12
|
+
help: Register a local repository
|
13
|
+
args:
|
14
|
+
- name: repo
|
15
|
+
required: true
|
16
|
+
help: Repository name.
|
17
|
+
|
18
|
+
command.alias:
|
19
|
+
help: Specify one or more aliases for this sub-command.
|
20
|
+
url: https://bashly.dannyb.co/configuration/command/#alias
|
21
|
+
example: |-
|
22
|
+
# Define a single alias
|
23
|
+
command:
|
24
|
+
name: download
|
25
|
+
alias: d
|
26
|
+
|
27
|
+
# Define multiple aliases
|
28
|
+
command:
|
29
|
+
name: download
|
30
|
+
alias: [d, pull]
|
31
|
+
|
32
|
+
# Run this command with anything that starts with 's'.
|
33
|
+
command:
|
34
|
+
name: server
|
35
|
+
alias: s*
|
36
|
+
|
37
|
+
command.args:
|
38
|
+
help: Define a list of positional arguments. See `arg` for reference.
|
39
|
+
url: https://bashly.dannyb.co/configuration/command/#args
|
40
|
+
example: |-
|
41
|
+
args:
|
42
|
+
- name: repo
|
43
|
+
required: true
|
44
|
+
help: Repository name.
|
45
|
+
|
46
|
+
command.catch_all:
|
47
|
+
help: Specify that this command should allow for additional arbitrary arguments or flags.
|
48
|
+
url: https://bashly.dannyb.co/configuration/command/#catch_all
|
49
|
+
example: |-
|
50
|
+
commands:
|
51
|
+
- name: download
|
52
|
+
help: Download one or more URLs
|
53
|
+
|
54
|
+
# Set to 'true' to simply enable this option
|
55
|
+
catch_all: true
|
56
|
+
|
57
|
+
- name: upload
|
58
|
+
help: Upload one or more files
|
59
|
+
|
60
|
+
# Use this extended syntax in order to also provide a usage label
|
61
|
+
# for these arguments, as well as specifying that at least one is
|
62
|
+
# required.
|
63
|
+
catch_all:
|
64
|
+
label: Files
|
65
|
+
help: Files to upload
|
66
|
+
required: true
|
67
|
+
|
68
|
+
command.commands:
|
69
|
+
help: Define a list of sub-commands. See `command` for reference.
|
70
|
+
url: https://bashly.dannyb.co/configuration/command/#commands
|
71
|
+
example: |-
|
72
|
+
commands:
|
73
|
+
- name: add
|
74
|
+
alias: a
|
75
|
+
help: Register a local repository
|
76
|
+
|
77
|
+
command.completions:
|
78
|
+
help: Specify a list of additional completion suggestions when used in conjunction with `bashly add comp`.
|
79
|
+
url: https://bashly.dannyb.co/configuration/command/#completions
|
80
|
+
example: |-
|
81
|
+
commands:
|
82
|
+
- name: view
|
83
|
+
help: View a directory, system user or a git branch
|
84
|
+
completions:
|
85
|
+
- <directory>
|
86
|
+
- <user>
|
87
|
+
- $(git branch 2> /dev/null)
|
88
|
+
|
89
|
+
command.default:
|
90
|
+
help: Specify that this sub-command will be executed implicitly.
|
91
|
+
url: https://bashly.dannyb.co/configuration/command/#default
|
92
|
+
example: |-
|
93
|
+
# This command will execute when the command line is not
|
94
|
+
# recognized.
|
95
|
+
commands:
|
96
|
+
- name: upload
|
97
|
+
help: Upload a file
|
98
|
+
default: true
|
99
|
+
|
100
|
+
# This command will execute when the command line is not
|
101
|
+
# recognized, or when it is empty.
|
102
|
+
commands:
|
103
|
+
- name: all
|
104
|
+
help: Run all tests
|
105
|
+
default: force
|
106
|
+
|
107
|
+
command.dependencies:
|
108
|
+
help: Specify a list of required external commands that are needed to run this command.
|
109
|
+
url: https://bashly.dannyb.co/configuration/command/#dependencies
|
110
|
+
example: |-
|
111
|
+
# Array syntax
|
112
|
+
dependencies:
|
113
|
+
- docker
|
114
|
+
- curl
|
115
|
+
|
116
|
+
# Hash syntax, to provide additional help message
|
117
|
+
dependencies:
|
118
|
+
docker: see https://docker.com for installation instructions
|
119
|
+
git: "install by running: sudo apt install git"
|
120
|
+
|
121
|
+
command.environment_variables:
|
122
|
+
help: Define a list of environment variables. See `environment_variable` for reference.
|
123
|
+
url: https://bashly.dannyb.co/configuration/command/#environment_variables
|
124
|
+
example: |-
|
125
|
+
environment_variables:
|
126
|
+
- name: config_path
|
127
|
+
help: Location of the config file
|
128
|
+
default: ~/config.ini
|
129
|
+
- name: api_key
|
130
|
+
help: Your API key
|
131
|
+
required: true
|
132
|
+
|
133
|
+
command.examples:
|
134
|
+
help: Define one or more example messages.
|
135
|
+
url: https://bashly.dannyb.co/configuration/command/#examples
|
136
|
+
example: |-
|
137
|
+
# Use an array of examples for simple one-liners.
|
138
|
+
examples:
|
139
|
+
- cli download example.com
|
140
|
+
- cli download example.com ./output -f
|
141
|
+
|
142
|
+
# Use a multi-line string when you need more control.
|
143
|
+
# Note the use of the '|-' marker that tells YAML to use the
|
144
|
+
# string as is, including the newlines it contains.
|
145
|
+
examples: |-
|
146
|
+
Upload a file
|
147
|
+
$ cli upload profile.png -u admin -p s3cr3t
|
148
|
+
|
149
|
+
Upload a file (you will be prompted to provide a password)
|
150
|
+
$ cli upload profile.png --user admin
|
151
|
+
|
152
|
+
command.expose:
|
153
|
+
help: Specify that the sub-commands of this command should be visible when showing the usage of its parent.
|
154
|
+
url: https://bashly.dannyb.co/configuration/command/#expose
|
155
|
+
example: |-
|
156
|
+
name: cli
|
157
|
+
commands:
|
158
|
+
- name: config
|
159
|
+
help: Config management commands
|
160
|
+
|
161
|
+
# Set to 'true' to show both 'config edit' and 'config show' when
|
162
|
+
# running 'cli --help'
|
163
|
+
expose: true
|
164
|
+
commands:
|
165
|
+
- name: edit
|
166
|
+
help: Edit config file
|
167
|
+
- name: show
|
168
|
+
help: Show config file
|
169
|
+
|
170
|
+
- name: server
|
171
|
+
help: Server management commands
|
172
|
+
|
173
|
+
# Set to 'always' to also show the usage of the sub-commands when
|
174
|
+
# running 'cli' without arguments.
|
175
|
+
expose: always
|
176
|
+
|
177
|
+
commands:
|
178
|
+
- name: start
|
179
|
+
help: Start the server
|
180
|
+
- name: stop
|
181
|
+
help: Stop the server
|
182
|
+
|
183
|
+
command.extensible:
|
184
|
+
help: Specify that this command can be extended by external means.
|
185
|
+
url: https://bashly.dannyb.co/configuration/command/#extensible
|
186
|
+
example: |-
|
187
|
+
name: mygit
|
188
|
+
help: Wrapper for git
|
189
|
+
version: 0.1.0
|
190
|
+
|
191
|
+
# Set to 'true' to allow extending it by creating executables in the
|
192
|
+
# path named 'mygit-*'.
|
193
|
+
extensible: true
|
194
|
+
|
195
|
+
# Set to another executable name to delegate all unknown commands
|
196
|
+
# to it.
|
197
|
+
extensible: git
|
198
|
+
|
199
|
+
command.filename:
|
200
|
+
help: Specify the path (relative to src) to the partial source code file.
|
201
|
+
url: https://bashly.dannyb.co/configuration/command/#filename
|
202
|
+
example: |-
|
203
|
+
commands:
|
204
|
+
- name: connect
|
205
|
+
help: Connect to server
|
206
|
+
filename: admin_commands/list.sh
|
207
|
+
|
208
|
+
command.filters:
|
209
|
+
help: Specify a list of custom filter functions that will prevent the command from running unless certain conditions are met.
|
210
|
+
url: https://bashly.dannyb.co/configuration/command/#filters
|
211
|
+
example: |-
|
212
|
+
commands:
|
213
|
+
- name: container
|
214
|
+
help: Perform actions on a docker container
|
215
|
+
|
216
|
+
# When the command is executed, your script will look for a function
|
217
|
+
# named 'filter_docker_running' and execute it. If it prints a string,
|
218
|
+
# it will be considered an error and the command execution will be
|
219
|
+
# halted.
|
220
|
+
filters:
|
221
|
+
- docker_running
|
222
|
+
|
223
|
+
# Example function (put somewhere in src/lib)
|
224
|
+
filter_docker_running() {
|
225
|
+
docker info >/dev/null 2>&1 || echo "Docker must be running"
|
226
|
+
}
|
227
|
+
|
228
|
+
command.flags:
|
229
|
+
help: Define a list of option flags. See `flag` for reference.
|
230
|
+
url: https://bashly.dannyb.co/configuration/command/#flags
|
231
|
+
example: |-
|
232
|
+
flags:
|
233
|
+
- long: --purge
|
234
|
+
short: -p
|
235
|
+
help: Also remove the local directory.
|
236
|
+
|
237
|
+
command.footer:
|
238
|
+
help: Specify a message to show at the bottom of the help text.
|
239
|
+
url: https://bashly.dannyb.co/configuration/command/#footer
|
240
|
+
example: |-
|
241
|
+
footer: For further help visit https://my.docs-site.com
|
242
|
+
|
243
|
+
command.function:
|
244
|
+
help: Specify a different base function name for this command.
|
245
|
+
url: https://bashly.dannyb.co/configuration/command/#function
|
246
|
+
example: |-
|
247
|
+
commands:
|
248
|
+
- name: container-start
|
249
|
+
help: Start a new container (deprecated)
|
250
|
+
|
251
|
+
# Override the name of the internal functions bashly uses. This is
|
252
|
+
# needed in this case since the command 'container-start' and the
|
253
|
+
# nested command 'container start' will have the same underlying
|
254
|
+
# function name otherwise.
|
255
|
+
function: deprecated_container_start
|
256
|
+
footer: This command is deprecated, use 'container start' instead
|
257
|
+
|
258
|
+
- name: container
|
259
|
+
help: Container commands
|
260
|
+
commands:
|
261
|
+
- name: start
|
262
|
+
help: Start a new container
|
263
|
+
|
264
|
+
command.group:
|
265
|
+
help: Specify the group that this command belongs to.
|
266
|
+
url: https://bashly.dannyb.co/configuration/command/#group
|
267
|
+
example: |-
|
268
|
+
command:
|
269
|
+
name: start
|
270
|
+
help: Start the server
|
271
|
+
group: Server
|
272
|
+
|
273
|
+
command.help:
|
274
|
+
help: Specify the help text to show when displaying usage.
|
275
|
+
url: https://bashly.dannyb.co/configuration/command/#help
|
276
|
+
example: |-
|
277
|
+
name: docker
|
278
|
+
help: Runtime for containers
|
279
|
+
|
280
|
+
commands:
|
281
|
+
- name: images
|
282
|
+
help: Manage images
|
283
|
+
|
284
|
+
command.name:
|
285
|
+
help: Specify the name of the command. This option is required.
|
286
|
+
url: https://bashly.dannyb.co/configuration/command/#name
|
287
|
+
example: |-
|
288
|
+
name: docker
|
289
|
+
help: Runtime for containers
|
290
|
+
|
291
|
+
commands:
|
292
|
+
- name: images
|
293
|
+
help: Manage images
|
294
|
+
|
295
|
+
command.private:
|
296
|
+
help: Specify that this command should not be displayed in the help text.
|
297
|
+
url: https://bashly.dannyb.co/configuration/command/#private
|
298
|
+
example: |-
|
299
|
+
commands:
|
300
|
+
- name: completions
|
301
|
+
help: Send bash completions
|
302
|
+
private: true
|
303
|
+
|
304
|
+
command.version:
|
305
|
+
help: Specify the version to show when running with `--version`.
|
306
|
+
url: https://bashly.dannyb.co/configuration/command/#version
|
307
|
+
example: |-
|
308
|
+
name: rush
|
309
|
+
help: Personal package manager
|
310
|
+
version: 0.6.5
|
@@ -0,0 +1,54 @@
|
|
1
|
+
environment_variable:
|
2
|
+
help: Define environment variables that will be in use in your script.
|
3
|
+
url: https://bashly.dannyb.co/configuration/environment-variable/
|
4
|
+
example: |-
|
5
|
+
environment_variables:
|
6
|
+
- name: config_path
|
7
|
+
help: Location of the config file
|
8
|
+
default: ~/config.ini
|
9
|
+
- name: api_key
|
10
|
+
help: Your API key
|
11
|
+
required: true
|
12
|
+
|
13
|
+
environment_variable.default:
|
14
|
+
help: Specify the value to apply when not provided by the user.
|
15
|
+
url: https://bashly.dannyb.co/configuration/environment-variable/#default
|
16
|
+
example: |-
|
17
|
+
environment_variables:
|
18
|
+
- name: config_path
|
19
|
+
help: Location of the config file
|
20
|
+
default: ~/config.ini
|
21
|
+
|
22
|
+
environment_variable.help:
|
23
|
+
help: Specify the help message for this variable.
|
24
|
+
url: https://bashly.dannyb.co/configuration/environment-variable/#help
|
25
|
+
example: |-
|
26
|
+
environment_variables:
|
27
|
+
- name: api_key
|
28
|
+
help: Your API key
|
29
|
+
|
30
|
+
environment_variable.name:
|
31
|
+
help: Specify the lowercase name of the variable.
|
32
|
+
url: https://bashly.dannyb.co/configuration/environment-variable/#name
|
33
|
+
example: |-
|
34
|
+
environment_variables:
|
35
|
+
- name: api_key
|
36
|
+
help: Your API key
|
37
|
+
|
38
|
+
environment_variable.private:
|
39
|
+
help: Specify that this environment variable should not be advertised in the usage text. Only makes sense when accompanied by `default`.
|
40
|
+
url: https://bashly.dannyb.co/configuration/environment-variable/#private
|
41
|
+
example: |-
|
42
|
+
environment_variables:
|
43
|
+
- name: editor
|
44
|
+
help: Editor to use
|
45
|
+
default: vim
|
46
|
+
private: true
|
47
|
+
|
48
|
+
environment_variable.required:
|
49
|
+
help: Specify that this variable is required.
|
50
|
+
url: https://bashly.dannyb.co/configuration/environment-variable/#required
|
51
|
+
example: |-
|
52
|
+
- name: api_key
|
53
|
+
help: Your API key
|
54
|
+
required: true
|
@@ -0,0 +1,163 @@
|
|
1
|
+
flag:
|
2
|
+
help: Define option flags.
|
3
|
+
url: https://bashly.dannyb.co/configuration/flag/
|
4
|
+
example: |-
|
5
|
+
flags:
|
6
|
+
- long: --ssh
|
7
|
+
short: -s
|
8
|
+
help: Clone using SSH
|
9
|
+
|
10
|
+
- long: --user
|
11
|
+
short: -u
|
12
|
+
arg: name
|
13
|
+
help: Repository user name
|
14
|
+
required: true
|
15
|
+
|
16
|
+
flag.allowed:
|
17
|
+
help: Specify a list of allowed values. Can be used in conjunction with `default` and `required`, and must be accompanied by `arg`.
|
18
|
+
url: https://bashly.dannyb.co/configuration/flag/#allowed
|
19
|
+
example: |-
|
20
|
+
flags:
|
21
|
+
- long: --user
|
22
|
+
short: -u
|
23
|
+
arg: name
|
24
|
+
help: User name
|
25
|
+
|
26
|
+
# allowed + required
|
27
|
+
allowed: [user, admin]
|
28
|
+
required: true
|
29
|
+
|
30
|
+
- long: --protocol
|
31
|
+
short: -p
|
32
|
+
arg: type
|
33
|
+
help: Protocol to connect with
|
34
|
+
|
35
|
+
# allowed + default
|
36
|
+
allowed: [ftp, ssh, http]
|
37
|
+
default: ssh
|
38
|
+
|
39
|
+
flag.arg:
|
40
|
+
help: Specify the name of the argument for this flag, in case it requires any.
|
41
|
+
url: https://bashly.dannyb.co/configuration/flag/#arg
|
42
|
+
example: |-
|
43
|
+
flags:
|
44
|
+
- long: --ssh
|
45
|
+
short: -s
|
46
|
+
help: Clone using SSH
|
47
|
+
|
48
|
+
flag.completions:
|
49
|
+
help: Specify a list of additional completion suggestions when used in conjunction with `bashly add comp`. Must be accompanied by `arg`.
|
50
|
+
url: https://bashly.dannyb.co/configuration/flag/#completions
|
51
|
+
example: |-
|
52
|
+
flags:
|
53
|
+
- long: --user
|
54
|
+
arg: username
|
55
|
+
completions:
|
56
|
+
- <user>
|
57
|
+
|
58
|
+
# Anything in the 'allowed' option is automatically added as a completion.
|
59
|
+
- long: --protocol
|
60
|
+
arg: protocol
|
61
|
+
allowed:
|
62
|
+
- ssh
|
63
|
+
- telnet
|
64
|
+
|
65
|
+
flag.conflicts:
|
66
|
+
help: Specify that this flag is mutually exclusive with one or more other flags. Use the long name of these conflicting flags.
|
67
|
+
url: https://bashly.dannyb.co/configuration/flag/#conflicts
|
68
|
+
example: |-
|
69
|
+
flags:
|
70
|
+
- long: --cache
|
71
|
+
help: Enable cache
|
72
|
+
|
73
|
+
# Running --cache with --no-cache is not permitted
|
74
|
+
conflicts: [--no-cache]
|
75
|
+
|
76
|
+
- long: --no-cache
|
77
|
+
help: Disable cache
|
78
|
+
|
79
|
+
# Running --no-cache with --cache or with --fast is not permitted
|
80
|
+
conflicts: [--cache, --fast]
|
81
|
+
|
82
|
+
- long: --fast
|
83
|
+
help: Run faster
|
84
|
+
|
85
|
+
# Make sure to add the conflicting flags on both sides of the conflict
|
86
|
+
conflicts: [--no-cache]
|
87
|
+
|
88
|
+
flag.default:
|
89
|
+
help: Specify the value to apply when not provided by the user.
|
90
|
+
url: https://bashly.dannyb.co/configuration/flag/#default
|
91
|
+
example: |-
|
92
|
+
flags:
|
93
|
+
- long: --environment
|
94
|
+
arg: name
|
95
|
+
help: Set environment name
|
96
|
+
default: production
|
97
|
+
|
98
|
+
flag.help:
|
99
|
+
help: Specify the help message for this flag.
|
100
|
+
url: https://bashly.dannyb.co/configuration/flag/#help
|
101
|
+
example: |-
|
102
|
+
flags:
|
103
|
+
- long: --cache
|
104
|
+
help: Enable cache
|
105
|
+
|
106
|
+
flag.long:
|
107
|
+
help: Specify the long form of the flag, including the -- prefix. Either `long` or `short` is required.
|
108
|
+
url: https://bashly.dannyb.co/configuration/flag/#long
|
109
|
+
example: |-
|
110
|
+
flags:
|
111
|
+
- long: --ssh
|
112
|
+
short: -s
|
113
|
+
help: Clone using SSH
|
114
|
+
|
115
|
+
flag.repeatable:
|
116
|
+
help: |-
|
117
|
+
Specify that this flag can be provided multiple times. When used on a flag with an argument, it will be received as a space-delimited string, which needs to be converted to an array with:
|
118
|
+
`eval "data=(${args[--data]})"`
|
119
|
+
|
120
|
+
url: https://bashly.dannyb.co/configuration/flag/#repeatable
|
121
|
+
example: |-
|
122
|
+
flags:
|
123
|
+
- long: --data
|
124
|
+
short: -d
|
125
|
+
arg: data
|
126
|
+
help: Provide data values
|
127
|
+
required: true
|
128
|
+
repeatable: true
|
129
|
+
|
130
|
+
- long: --verbose
|
131
|
+
short: -v
|
132
|
+
help: Set verbosity level
|
133
|
+
repeatable: true
|
134
|
+
|
135
|
+
flag.required:
|
136
|
+
help: Specify that this flag is required.
|
137
|
+
url: https://bashly.dannyb.co/configuration/flag/#required
|
138
|
+
example: |-
|
139
|
+
args:
|
140
|
+
- long: --user
|
141
|
+
arg: name
|
142
|
+
help: Repository user name
|
143
|
+
required: true
|
144
|
+
|
145
|
+
flag.short:
|
146
|
+
help: Specify the short form of the flag, including the - prefix. Either `long` or `short` is required.
|
147
|
+
url: https://bashly.dannyb.co/configuration/flag/#short
|
148
|
+
example: |-
|
149
|
+
- long: --user
|
150
|
+
short: -u
|
151
|
+
arg: name
|
152
|
+
help: Repository user name
|
153
|
+
|
154
|
+
flag.validate:
|
155
|
+
help: Apply custom validation functions. Must be accompanied by `arg`.
|
156
|
+
|
157
|
+
url: https://bashly.dannyb.co/configuration/flag/#validate
|
158
|
+
example: |-
|
159
|
+
flags:
|
160
|
+
- long: --config
|
161
|
+
arg: path
|
162
|
+
help: Load configuration from a file
|
163
|
+
validate: file_exists
|
data/lib/bashly/version.rb
CHANGED
@@ -24,6 +24,7 @@ elsif extensible.is_a? String
|
|
24
24
|
> printf "{{ strings[:invalid_command] }}\n" "$action" >&2
|
25
25
|
> exit 1
|
26
26
|
> fi
|
27
|
+
> ;;
|
27
28
|
>
|
28
29
|
|
29
30
|
elsif extensible
|
@@ -34,6 +35,7 @@ elsif extensible
|
|
34
35
|
> printf "{{ strings[:invalid_command] }}\n" "$action" >&2
|
35
36
|
> exit 1
|
36
37
|
> fi
|
38
|
+
> ;;
|
37
39
|
>
|
38
40
|
|
39
41
|
else
|
@@ -2,11 +2,11 @@ if default_args.any? or default_flags.any?
|
|
2
2
|
= view_marker
|
3
3
|
|
4
4
|
default_args.each do |arg|
|
5
|
-
> [[ -n ${args[{{ arg.name }}]:-} ]] || args[{{ arg.name }}]="{{ arg.default }}"
|
5
|
+
> [[ -n ${args['{{ arg.name }}']:-} ]] || args['{{ arg.name }}']="{{ arg.default }}"
|
6
6
|
end
|
7
7
|
|
8
8
|
default_flags.each do |flag|
|
9
|
-
> [[ -n ${args[{{ flag.long }}]:-} ]] || args[{{ flag.long }}]="{{ flag.default }}"
|
9
|
+
> [[ -n ${args['{{ flag.long }}']:-} ]] || args['{{ flag.long }}']="{{ flag.default }}"
|
10
10
|
end
|
11
11
|
|
12
12
|
>
|
@@ -4,14 +4,14 @@
|
|
4
4
|
> case "${1:-}" in
|
5
5
|
|
6
6
|
if root_command?
|
7
|
-
= short_flag_exist?("-v") ? "--version)" : "--version | -v)".indent(4)
|
7
|
+
= (short_flag_exist?("-v") ? "--version)" : "--version | -v)").indent(4)
|
8
8
|
> version_command
|
9
9
|
> exit
|
10
10
|
> ;;
|
11
11
|
>
|
12
12
|
end
|
13
13
|
|
14
|
-
= short_flag_exist?("-h") ? "--help)" : "--help | -h)".indent(4)
|
14
|
+
= (short_flag_exist?("-h") ? "--help)" : "--help | -h)").indent(4)
|
15
15
|
> long_usage=yes
|
16
16
|
> <%= function_name %>_usage
|
17
17
|
> exit
|
@@ -3,9 +3,9 @@
|
|
3
3
|
if args.any?
|
4
4
|
condition = "if"
|
5
5
|
args.each do |arg|
|
6
|
-
> {{ condition }} [[ -z ${args[{{ arg.name }}]+x} ]]; then
|
6
|
+
> {{ condition }} [[ -z ${args['{{ arg.name }}']+x} ]]; then
|
7
7
|
= arg.render(:validations).indent 2
|
8
|
-
> args[{{ arg.name }}]=$1
|
8
|
+
> args['{{ arg.name }}']=$1
|
9
9
|
> shift
|
10
10
|
|
11
11
|
condition = "elif"
|
@@ -2,18 +2,17 @@
|
|
2
2
|
|
3
3
|
condition = "if"
|
4
4
|
args.each do |arg|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
= arg.render(:validations)
|
6
|
+
> {{ condition }} [[ -z ${args['{{ arg.name }}']+x} ]]; then
|
8
7
|
if arg.repeatable
|
9
|
-
> args[{{ arg.name }}]="\"$1\""
|
8
|
+
> args['{{ arg.name }}']="\"$1\""
|
10
9
|
> shift
|
11
10
|
> else
|
12
|
-
> args[{{ arg.name }}]="${args[{{ arg.name }}]} \"$1\""
|
11
|
+
> args['{{ arg.name }}']="${args[{{ arg.name }}]} \"$1\""
|
13
12
|
> shift
|
14
13
|
|
15
14
|
else
|
16
|
-
> args[{{ arg.name }}]=$1
|
15
|
+
> args['{{ arg.name }}']=$1
|
17
16
|
> shift
|
18
17
|
|
19
18
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
if args.any?
|
4
4
|
condition = "if"
|
5
5
|
args.each do |arg|
|
6
|
-
> {{ condition }} [[ -z ${args[{{ arg.name }}]+x} ]]; then
|
6
|
+
> {{ condition }} [[ -z ${args['{{ arg.name }}']+x} ]]; then
|
7
7
|
> {{ arg.render(:validations).indent 2 }}
|
8
|
-
> args[{{ arg.name }}]=$1
|
8
|
+
> args['{{ arg.name }}']=$1
|
9
9
|
> shift
|
10
10
|
|
11
11
|
condition = "elif"
|
@@ -2,7 +2,7 @@ if required_args.any?
|
|
2
2
|
= view_marker
|
3
3
|
|
4
4
|
required_args.each do |arg|
|
5
|
-
> if [[ -z ${args[{{ arg.name }}]+x} ]]; then
|
5
|
+
> if [[ -z ${args['{{ arg.name }}']+x} ]]; then
|
6
6
|
> printf "{{ strings[:missing_required_argument] % { arg: arg.name.upcase, usage: usage_string } }}\n" >&2
|
7
7
|
> exit 1
|
8
8
|
> fi
|
@@ -2,7 +2,7 @@ if required_flags.any?
|
|
2
2
|
= view_marker
|
3
3
|
|
4
4
|
required_flags.each do |flag|
|
5
|
-
> if [[ -z ${args[{{ flag.long }}]+x} ]]; then
|
5
|
+
> if [[ -z ${args['{{ flag.long }}']+x} ]]; then
|
6
6
|
> printf "{{ strings[:missing_required_flag] % { usage: flag.usage_string } }}\n" >&2
|
7
7
|
> exit 1
|
8
8
|
> fi
|
@@ -12,7 +12,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
|
|
12
12
|
> done
|
13
13
|
|
14
14
|
else
|
15
|
-
> if [[ ! ${args[{{ arg.name }}]} =~ ^({{ arg.allowed.join '|' }})$ ]]; then
|
15
|
+
> if [[ ! ${args['{{ arg.name }}']} =~ ^({{ arg.allowed.join '|' }})$ ]]; then
|
16
16
|
> printf "%s\n" "{{ strings[:disallowed_argument] % { name: arg.name, allowed: arg.allowed.join(', ') } }}" >&2
|
17
17
|
> exit 1
|
18
18
|
> fi
|
@@ -31,7 +31,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
|
|
31
31
|
> done
|
32
32
|
|
33
33
|
else
|
34
|
-
> if [[ ! ${args[{{ flag.name }}]} =~ ^({{ flag.allowed.join '|' }})$ ]]; then
|
34
|
+
> if [[ ! ${args['{{ flag.name }}']} =~ ^({{ flag.allowed.join '|' }})$ ]]; then
|
35
35
|
> printf "%s\n" "{{ strings[:disallowed_flag] % { name: flag.name, allowed: flag.allowed.join(', ') } }}" >&2
|
36
36
|
> exit 1
|
37
37
|
> fi
|
@@ -4,14 +4,14 @@
|
|
4
4
|
= render(:validations).indent 2
|
5
5
|
|
6
6
|
if repeatable
|
7
|
-
> if [[ -z ${args[{{ name }}]+x} ]]; then
|
8
|
-
> args[{{ name }}]="\"$2\""
|
7
|
+
> if [[ -z ${args['{{ name }}']+x} ]]; then
|
8
|
+
> args['{{ name }}']="\"$2\""
|
9
9
|
> else
|
10
|
-
> args[{{ name }}]="${args[{{ name }}]} \"$2\""
|
10
|
+
> args['{{ name }}']="${args[{{ name }}]} \"$2\""
|
11
11
|
> fi
|
12
12
|
|
13
13
|
else
|
14
|
-
> args[{{ name }}]="$2"
|
14
|
+
> args['{{ name }}']="$2"
|
15
15
|
|
16
16
|
end
|
17
17
|
|
@@ -3,7 +3,7 @@ if conflicts
|
|
3
3
|
= view_marker
|
4
4
|
|
5
5
|
if conflicts.count == 1
|
6
|
-
> if [[ -n "${args[{{ conflicts.first }}]:-}" ]]; then
|
6
|
+
> if [[ -n "${args['{{ conflicts.first }}']:-}" ]]; then
|
7
7
|
> printf "{{ strings[:conflicting_flags] }}\n" "$key" "{{ conflicts.first }}" >&2
|
8
8
|
> exit 1
|
9
9
|
> fi
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bashly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: completely
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/bashly/cli.rb
|
122
122
|
- lib/bashly/commands/add.rb
|
123
123
|
- lib/bashly/commands/base.rb
|
124
|
+
- lib/bashly/commands/doc.rb
|
124
125
|
- lib/bashly/commands/generate.rb
|
125
126
|
- lib/bashly/commands/init.rb
|
126
127
|
- lib/bashly/commands/preview.rb
|
@@ -132,6 +133,10 @@ files:
|
|
132
133
|
- lib/bashly/config.rb
|
133
134
|
- lib/bashly/config_validator.rb
|
134
135
|
- lib/bashly/deprecation.rb
|
136
|
+
- lib/bashly/docs/arg.yml
|
137
|
+
- lib/bashly/docs/command.yml
|
138
|
+
- lib/bashly/docs/env.yml
|
139
|
+
- lib/bashly/docs/flag.yml
|
135
140
|
- lib/bashly/exceptions.rb
|
136
141
|
- lib/bashly/extensions/array.rb
|
137
142
|
- lib/bashly/extensions/file.rb
|
@@ -247,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
252
|
- !ruby/object:Gem::Version
|
248
253
|
version: '0'
|
249
254
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
255
|
+
rubygems_version: 3.4.0
|
251
256
|
signing_key:
|
252
257
|
specification_version: 4
|
253
258
|
summary: Bash Command Line Tool Generator
|