bashly 1.2.2 → 1.2.4
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/lib/bashly/config_validator.rb +8 -2
- data/lib/bashly/docs/command.yml +21 -0
- data/lib/bashly/docs/var.yml +51 -0
- data/lib/bashly/libraries/colors/colors.sh +9 -0
- data/lib/bashly/libraries/ini/ini.sh +1 -0
- data/lib/bashly/script/command.rb +2 -1
- data/lib/bashly/script/introspection/variables.rb +16 -0
- data/lib/bashly/script/variable.rb +11 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/fixed_flags_filter.gtx +2 -1
- data/lib/bashly/views/command/function.gtx +1 -0
- data/lib/bashly/views/command/run.gtx +1 -0
- data/lib/bashly/views/command/variables.gtx +5 -0
- data/lib/bashly/views/variable/definition.gtx +28 -0
- data/lib/bashly.rb +2 -2
- metadata +48 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cc30c6d61489ca1a61dc4c8380476d9db8f6e5298bb5c079b964966e7266dbd
|
4
|
+
data.tar.gz: 695681a9817474ed89e833ea4b0cdd5fb2c7ecda7dfb032cc017540f0f04a986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d3786ae3d2bd0171705eaa15fd644228e10774023c3042255102e81b7570af318fbe2e6dbae301c319e12830dd914fbfe3385fc90aca5dcd1dd49f8884e29c8
|
7
|
+
data.tar.gz: 197fab7301ad30ccb93bf80c799d4aa978626220db9f748ab5048da9a857b2a47b71777c42a641aae3718d8e57d2923a672ea4e859280d097295bbd2fc4c3768
|
@@ -24,7 +24,7 @@ module Bashly
|
|
24
24
|
def assert_catch_all(key, value)
|
25
25
|
return unless value
|
26
26
|
|
27
|
-
assert [TrueClass, String, Hash].include?(value.class),
|
27
|
+
assert [TrueClass, FalseClass, String, Hash].include?(value.class),
|
28
28
|
"#{key} must be a boolean, a string or a hash"
|
29
29
|
|
30
30
|
assert_catch_all_hash key, value if value.is_a? Hash
|
@@ -77,7 +77,7 @@ module Bashly
|
|
77
77
|
def assert_extensible(key, value)
|
78
78
|
return unless value
|
79
79
|
|
80
|
-
assert [TrueClass, String].include?(value.class),
|
80
|
+
assert [TrueClass, FalseClass, String].include?(value.class),
|
81
81
|
"#{key} must be a boolean or a string"
|
82
82
|
end
|
83
83
|
|
@@ -173,6 +173,11 @@ module Bashly
|
|
173
173
|
refute value['required'] && value['default'], "#{key} cannot have both nub`required` and nub`default`"
|
174
174
|
end
|
175
175
|
|
176
|
+
def assert_var(key, value)
|
177
|
+
assert_hash key, value, keys: Script::Variable.option_keys
|
178
|
+
assert_string "#{key}.name", value['name']
|
179
|
+
end
|
180
|
+
|
176
181
|
def assert_command(key, value)
|
177
182
|
assert_hash key, value, keys: Script::Command.option_keys
|
178
183
|
|
@@ -207,6 +212,7 @@ module Bashly
|
|
207
212
|
assert_array "#{key}.completions", value['completions'], of: :string
|
208
213
|
assert_array "#{key}.filters", value['filters'], of: :string
|
209
214
|
assert_array "#{key}.environment_variables", value['environment_variables'], of: :env_var
|
215
|
+
assert_array "#{key}.variables", value['variables'], of: :var
|
210
216
|
|
211
217
|
assert_uniq "#{key}.commands", value['commands'], %w[name alias]
|
212
218
|
assert_uniq "#{key}.flags", value['flags'], 'long'
|
data/lib/bashly/docs/command.yml
CHANGED
@@ -309,6 +309,27 @@ command.private:
|
|
309
309
|
help: Send bash completions
|
310
310
|
private: true
|
311
311
|
|
312
|
+
command.variables:
|
313
|
+
help: Define a list of global bash variables. See `variable` for reference.
|
314
|
+
url: https://bashly.dannyb.co/configuration/command/#variables
|
315
|
+
example: |-
|
316
|
+
variables:
|
317
|
+
# Simple value
|
318
|
+
- name: output_folder
|
319
|
+
value: output
|
320
|
+
|
321
|
+
# Array
|
322
|
+
- name: download_sources
|
323
|
+
value:
|
324
|
+
- youtube
|
325
|
+
- instagram
|
326
|
+
|
327
|
+
# Associative array
|
328
|
+
- name: zip_options
|
329
|
+
value:
|
330
|
+
pattern: "*.json"
|
331
|
+
compression_level: fast
|
332
|
+
|
312
333
|
command.version:
|
313
334
|
help: Specify the version to show when running with `--version`.
|
314
335
|
url: https://bashly.dannyb.co/configuration/command/#version
|
@@ -0,0 +1,51 @@
|
|
1
|
+
variable:
|
2
|
+
help: Define variables that will be available to your script.
|
3
|
+
url: https://bashly.dannyb.co/configuration/variable/
|
4
|
+
example: |-
|
5
|
+
variables:
|
6
|
+
# Simple value
|
7
|
+
- name: output_folder
|
8
|
+
value: output
|
9
|
+
|
10
|
+
# Array
|
11
|
+
- name: download_sources
|
12
|
+
value:
|
13
|
+
- youtube
|
14
|
+
- instagram
|
15
|
+
|
16
|
+
# Associative array
|
17
|
+
- name: zip_options
|
18
|
+
value:
|
19
|
+
pattern: "*.json"
|
20
|
+
compression_level: fast
|
21
|
+
|
22
|
+
variable.name:
|
23
|
+
help: Specify the name of the variable.
|
24
|
+
url: https://bashly.dannyb.co/configuration/variable/#name
|
25
|
+
example: |-
|
26
|
+
variables:
|
27
|
+
- name: output_folder
|
28
|
+
value: output
|
29
|
+
|
30
|
+
variable.value:
|
31
|
+
help: |-
|
32
|
+
Specify the value for this variable.
|
33
|
+
This can be any value type, including array and hash (associative array).
|
34
|
+
url: https://bashly.dannyb.co/configuration/variable/#value
|
35
|
+
example: |-
|
36
|
+
variables:
|
37
|
+
# Simple value
|
38
|
+
- name: output_folder
|
39
|
+
value: output
|
40
|
+
|
41
|
+
# Array
|
42
|
+
- name: download_sources
|
43
|
+
value:
|
44
|
+
- youtube
|
45
|
+
- instagram
|
46
|
+
|
47
|
+
# Associative array
|
48
|
+
- name: zip_options
|
49
|
+
value:
|
50
|
+
pattern: "*.json"
|
51
|
+
compression_level: fast
|
@@ -26,17 +26,26 @@ yellow() { print_in_color "\e[33m" "$*"; }
|
|
26
26
|
blue() { print_in_color "\e[34m" "$*"; }
|
27
27
|
magenta() { print_in_color "\e[35m" "$*"; }
|
28
28
|
cyan() { print_in_color "\e[36m" "$*"; }
|
29
|
+
black() { print_in_color "\e[30m" "$*"; }
|
30
|
+
white() { print_in_color "\e[37m" "$*"; }
|
31
|
+
|
29
32
|
bold() { print_in_color "\e[1m" "$*"; }
|
30
33
|
underlined() { print_in_color "\e[4m" "$*"; }
|
34
|
+
|
31
35
|
red_bold() { print_in_color "\e[1;31m" "$*"; }
|
32
36
|
green_bold() { print_in_color "\e[1;32m" "$*"; }
|
33
37
|
yellow_bold() { print_in_color "\e[1;33m" "$*"; }
|
34
38
|
blue_bold() { print_in_color "\e[1;34m" "$*"; }
|
35
39
|
magenta_bold() { print_in_color "\e[1;35m" "$*"; }
|
36
40
|
cyan_bold() { print_in_color "\e[1;36m" "$*"; }
|
41
|
+
black_bold() { print_in_color "\e[1;30m" "$*"; }
|
42
|
+
white_bold() { print_in_color "\e[1;37m" "$*"; }
|
43
|
+
|
37
44
|
red_underlined() { print_in_color "\e[4;31m" "$*"; }
|
38
45
|
green_underlined() { print_in_color "\e[4;32m" "$*"; }
|
39
46
|
yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
|
40
47
|
blue_underlined() { print_in_color "\e[4;34m" "$*"; }
|
41
48
|
magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
|
42
49
|
cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
|
50
|
+
black_underlined() { print_in_color "\e[4;30m" "$*"; }
|
51
|
+
white_underlined() { print_in_color "\e[4;37m" "$*"; }
|
@@ -8,6 +8,7 @@ module Bashly
|
|
8
8
|
include Introspection::EnvironmentVariables
|
9
9
|
include Introspection::Examples
|
10
10
|
include Introspection::Flags
|
11
|
+
include Introspection::Variables
|
11
12
|
include Introspection::Visibility
|
12
13
|
|
13
14
|
class << self
|
@@ -17,7 +18,7 @@ module Bashly
|
|
17
18
|
default dependencies environment_variables examples
|
18
19
|
extensible expose filename filters flags
|
19
20
|
footer function group help name
|
20
|
-
private version
|
21
|
+
private variables version
|
21
22
|
]
|
22
23
|
end
|
23
24
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Bashly
|
2
|
+
module Script
|
3
|
+
module Introspection
|
4
|
+
module Variables
|
5
|
+
# Returns an array of Variable objects
|
6
|
+
def variables
|
7
|
+
return [] unless options['variables']
|
8
|
+
|
9
|
+
options['variables'].map do |options|
|
10
|
+
Variable.new options
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/bashly/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
= view_marker
|
2
|
+
|
3
|
+
case value
|
4
|
+
when Array
|
5
|
+
if value.empty?
|
6
|
+
> declare -a {{ name }}=()
|
7
|
+
else
|
8
|
+
> declare -a {{ name }}=(
|
9
|
+
value.each do |v|
|
10
|
+
> "{{ v }}"
|
11
|
+
end
|
12
|
+
> )
|
13
|
+
end
|
14
|
+
when Hash
|
15
|
+
if value.empty?
|
16
|
+
> declare -A {{ name }}=()
|
17
|
+
else
|
18
|
+
> declare -A {{ name }}=(
|
19
|
+
value.each do |k, v|
|
20
|
+
> ["{{ k }}"]="{{ v }}"
|
21
|
+
end
|
22
|
+
> )
|
23
|
+
end
|
24
|
+
when String, NilClass
|
25
|
+
> {{ name }}="{{ value }}"
|
26
|
+
else
|
27
|
+
> {{ name }}={{ value }}
|
28
|
+
end
|
data/lib/bashly.rb
CHANGED
@@ -22,13 +22,13 @@ module Bashly
|
|
22
22
|
module Script
|
23
23
|
autoloads 'bashly/script', %i[
|
24
24
|
Argument Base CatchAll Command Dependency EnvironmentVariable Flag
|
25
|
-
Wrapper
|
25
|
+
Variable Wrapper
|
26
26
|
]
|
27
27
|
|
28
28
|
module Introspection
|
29
29
|
autoloads 'bashly/script/introspection', %i[
|
30
30
|
Arguments Commands Dependencies EnvironmentVariables Examples Flags
|
31
|
-
Visibility
|
31
|
+
Variables Visibility
|
32
32
|
]
|
33
33
|
end
|
34
34
|
end
|
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: 1.2.
|
4
|
+
version: 1.2.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: 2024-
|
11
|
+
date: 2024-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -128,6 +128,46 @@ dependencies:
|
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0.7'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: logger
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1'
|
138
|
+
- - "<"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '3'
|
141
|
+
type: :runtime
|
142
|
+
prerelease: false
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '1'
|
148
|
+
- - "<"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '3'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: ostruct
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- - "<"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '2'
|
161
|
+
type: :runtime
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
- - "<"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '2'
|
131
171
|
- !ruby/object:Gem::Dependency
|
132
172
|
name: psych
|
133
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,6 +224,7 @@ files:
|
|
184
224
|
- lib/bashly/docs/command.yml
|
185
225
|
- lib/bashly/docs/env.yml
|
186
226
|
- lib/bashly/docs/flag.yml
|
227
|
+
- lib/bashly/docs/var.yml
|
187
228
|
- lib/bashly/exceptions.rb
|
188
229
|
- lib/bashly/extensions/array.rb
|
189
230
|
- lib/bashly/extensions/file.rb
|
@@ -240,7 +281,9 @@ files:
|
|
240
281
|
- lib/bashly/script/introspection/environment_variables.rb
|
241
282
|
- lib/bashly/script/introspection/examples.rb
|
242
283
|
- lib/bashly/script/introspection/flags.rb
|
284
|
+
- lib/bashly/script/introspection/variables.rb
|
243
285
|
- lib/bashly/script/introspection/visibility.rb
|
286
|
+
- lib/bashly/script/variable.rb
|
244
287
|
- lib/bashly/script/wrapper.rb
|
245
288
|
- lib/bashly/settings.rb
|
246
289
|
- lib/bashly/templates/bashly.yml
|
@@ -294,6 +337,7 @@ files:
|
|
294
337
|
- lib/bashly/views/command/user_hooks.gtx
|
295
338
|
- lib/bashly/views/command/user_lib.gtx
|
296
339
|
- lib/bashly/views/command/validations.gtx
|
340
|
+
- lib/bashly/views/command/variables.gtx
|
297
341
|
- lib/bashly/views/command/version_command.gtx
|
298
342
|
- lib/bashly/views/command/whitelist_filter.gtx
|
299
343
|
- lib/bashly/views/environment_variable/usage.gtx
|
@@ -305,6 +349,7 @@ files:
|
|
305
349
|
- lib/bashly/views/flag/needs.gtx
|
306
350
|
- lib/bashly/views/flag/usage.gtx
|
307
351
|
- lib/bashly/views/flag/validations.gtx
|
352
|
+
- lib/bashly/views/variable/definition.gtx
|
308
353
|
- lib/bashly/views/wrapper/bash3_bouncer.gtx
|
309
354
|
- lib/bashly/views/wrapper/header.gtx
|
310
355
|
- lib/bashly/views/wrapper/wrapper.gtx
|
@@ -332,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
377
|
- !ruby/object:Gem::Version
|
333
378
|
version: '0'
|
334
379
|
requirements: []
|
335
|
-
rubygems_version: 3.5.
|
380
|
+
rubygems_version: 3.5.22
|
336
381
|
signing_key:
|
337
382
|
specification_version: 4
|
338
383
|
summary: Bash Command Line Tool Generator
|