bashly 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bashly/cli.rb +1 -0
- data/lib/bashly/commands/doc.rb +90 -0
- data/lib/bashly/commands/validate.rb +2 -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/extensions/string.rb +8 -0
- data/lib/bashly/settings.rb +5 -1
- data/lib/bashly/templates/settings.yml +12 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/argument/usage.gtx +1 -1
- data/lib/bashly/views/command/long_usage.gtx +1 -1
- data/lib/bashly/views/command/parse_requirements_while.gtx +9 -1
- data/lib/bashly/views/command/usage.gtx +1 -1
- data/lib/bashly/views/command/usage_args.gtx +1 -1
- data/lib/bashly/views/command/usage_commands.gtx +3 -3
- data/lib/bashly/views/command/usage_environment_variables.gtx +1 -1
- data/lib/bashly/views/command/usage_examples.gtx +1 -1
- data/lib/bashly/views/command/usage_fixed_flags.gtx +11 -2
- data/lib/bashly/views/environment_variable/usage.gtx +1 -1
- data/lib/bashly/views/flag/usage.gtx +1 -1
- data/lib/bashly.rb +0 -1
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 810dfb8f0b25029420a1479aa38d682a79787716112d9b5f9c816533fc3e97ea
|
4
|
+
data.tar.gz: c6782bd0bf01a475b137487dcdec634645484c877386b1ccaaa8432d53831595
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c6cb7413b619b50cd76ecfa66d704623780f05f3316e1e9bcb9e7a3c02a4a3b9a9215759e928e32e4d6492993fb5b5cbcb6ba0379bd0fe638f6ab1182b791a4
|
7
|
+
data.tar.gz: e83491e2a1ab364701351a74bbef05377bbe479521fe907b8f9b1dc3fa567be4f5b53f87c4f4d4dd4313e9fff16ab84e07dd5cbfae5ed7ff0f4c2d44b98d69bd
|
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
|
@@ -37,4 +37,12 @@ class String
|
|
37
37
|
"\t" * (::Regexp.last_match(1).size / tabstop)
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
def color(marker)
|
42
|
+
color = Bashly::Settings.usage_colors[marker.to_s]
|
43
|
+
return self unless color
|
44
|
+
|
45
|
+
text, spaces = match(/(.*?)(\s*)$/).captures
|
46
|
+
%[$(#{color} "#{text}")#{spaces}]
|
47
|
+
end
|
40
48
|
end
|
data/lib/bashly/settings.rb
CHANGED
@@ -4,7 +4,7 @@ module Bashly
|
|
4
4
|
include AssetHelper
|
5
5
|
|
6
6
|
attr_writer :compact_short_flags, :lib_dir, :partials_extension,
|
7
|
-
:source_dir, :strict, :tab_indent, :target_dir
|
7
|
+
:source_dir, :strict, :tab_indent, :target_dir, :usage_colors
|
8
8
|
|
9
9
|
def compact_short_flags
|
10
10
|
@compact_short_flags ||= get :compact_short_flags
|
@@ -50,6 +50,10 @@ module Bashly
|
|
50
50
|
@target_dir ||= get :target_dir
|
51
51
|
end
|
52
52
|
|
53
|
+
def usage_colors
|
54
|
+
@usage_colors ||= get :usage_colors
|
55
|
+
end
|
56
|
+
|
53
57
|
private
|
54
58
|
|
55
59
|
def get(key)
|
@@ -33,3 +33,15 @@ env: development
|
|
33
33
|
|
34
34
|
# The extension to use when reading/writing partial script snippets.
|
35
35
|
partials_extension: sh
|
36
|
+
|
37
|
+
# Display various usage elements in color by providing the name of the color
|
38
|
+
# function. The value for each property is a name of a function that is
|
39
|
+
# available in your script, for example: `green` or `bold`.
|
40
|
+
# You can run `bashly add colors` to add a standard colors library.
|
41
|
+
# This option cannot be set via environment variables.
|
42
|
+
usage_colors:
|
43
|
+
caption: ~
|
44
|
+
command: ~
|
45
|
+
arg: ~
|
46
|
+
flag: ~
|
47
|
+
environment_variable: ~
|
data/lib/bashly/version.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
maxlen = command_help_data.values.map(&:keys).flatten.map(&:size).max
|
4
4
|
|
5
5
|
command_help_data.each do |group, commands|
|
6
|
-
> printf "{{ group }}
|
6
|
+
> printf "%s\n" "{{ group.color(:caption) }}"
|
7
7
|
|
8
8
|
commands.each do |command, info|
|
9
9
|
if info[:help_only]
|
10
|
-
> [[ -n $long_usage ]] &&
|
10
|
+
> [[ -n $long_usage ]] && printf " %s {{ info[:summary] }}\n" "{{ command.ljust(maxlen).color(:command) }}"
|
11
11
|
else
|
12
|
-
>
|
12
|
+
> printf " %s {{ info[:summary] }}\n" "{{ command.ljust(maxlen).color(:command) }}"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -1,11 +1,20 @@
|
|
1
1
|
= view_marker
|
2
2
|
|
3
|
-
|
3
|
+
if short_flag_exist?("-h")
|
4
|
+
> printf " %s\n" "{{ '--help'.color(:flag) }}"
|
5
|
+
else
|
6
|
+
> printf " %s\n" "{{ '--help, -h'.color(:flag) }}"
|
7
|
+
end
|
8
|
+
|
4
9
|
> printf " {{ strings[:help_flag_text] }}\n"
|
5
10
|
> echo
|
6
11
|
|
7
12
|
if root_command?
|
8
|
-
|
13
|
+
if short_flag_exist?("-v")
|
14
|
+
> printf " %s\n" "{{ '--version'.color(:flag) }}"
|
15
|
+
else
|
16
|
+
> printf " %s\n" "{{ '--version, -v'.color(:flag) }}"
|
17
|
+
end
|
9
18
|
> printf " {{ strings[:version_flag_text] }}\n"
|
10
19
|
> echo
|
11
20
|
end
|
data/lib/bashly.rb
CHANGED
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.4
|
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-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: completely
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '1.0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '1.0'
|
111
111
|
description: Generate bash command line tools using YAML configuration
|
112
112
|
email: db@dannyben.com
|
113
113
|
executables:
|
@@ -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
|