bashly 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/lib/bashly/commands/doc.rb +1 -1
- data/lib/bashly/commands/generate.rb +1 -4
- data/lib/bashly/concerns/completions.rb +3 -3
- data/lib/bashly/config_validator.rb +10 -10
- data/lib/bashly/libraries/hooks/initialize.sh +6 -0
- data/lib/bashly/libraries/libraries.yml +3 -1
- data/lib/bashly/script/command.rb +6 -1
- data/lib/bashly/settings.rb +10 -4
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/default_assignments.gtx +1 -1
- data/lib/bashly/views/command/environment_variables_default.gtx +1 -1
- data/lib/bashly/views/command/initialize.gtx +5 -2
- data/lib/bashly/views/command/required_flags_filter.gtx +1 -1
- data/lib/bashly/views/command/whitelist_filter.gtx +2 -2
- metadata +5 -5
- data/lib/bashly/views/command/default_initialize_script.gtx +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8541b3056b57bf3b312972de9468334a8590dbf9c759a0a099de12230b164e4
|
4
|
+
data.tar.gz: 2ad5a9367d40f95fed80dcb5da2743469237f24e7935ba1d7530459adbc9dfc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bd9c8ce895b05bae99c0fa658a23816426c10d33ea965cd0186460da5de6e088f3a1c9f6acf5969ef84022db3c10321163a0740966162646b39744855c1984f
|
7
|
+
data.tar.gz: 12a626b4e5875110003c5a8b22ea9b289e63b0e05638ba37d25c353e73b86149e65b7e5b9e5460ae5c356c971057a2cef8d73a472f09f851533d64c665b71f2d
|
data/README.md
CHANGED
@@ -29,7 +29,12 @@ a [docker image](https://hub.docker.com/r/dannyben/bashly).
|
|
29
29
|
|
30
30
|
## Bashly is Sponsored By
|
31
31
|
|
32
|
-
<
|
32
|
+
<table>
|
33
|
+
<tr>
|
34
|
+
<td><a href="https://rhodecode.com/"><img src='support/img/RhodeCode-logo.png' width=240></a></td>
|
35
|
+
<td><a href="https://decisiohealth.com/"><img src='support/img/decisio-logo.png' width=240></a></td>
|
36
|
+
</tr>
|
37
|
+
</table>
|
33
38
|
|
34
39
|
|
35
40
|
## Documentation
|
@@ -69,7 +74,7 @@ Bashly is responsible for:
|
|
69
74
|
- **Bash completions**.
|
70
75
|
- and more.
|
71
76
|
|
72
|
-
|
77
|
+
## Contributing / Support
|
73
78
|
|
74
79
|
If you experience any issue, have a question or a suggestion, or if you wish
|
75
80
|
to contribute, feel free to [open an issue][issues] or
|
data/lib/bashly/commands/doc.rb
CHANGED
@@ -89,7 +89,7 @@ module Bashly
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def generated_files
|
92
|
-
Dir["#{Settings.source_dir}/**/*.*"]
|
92
|
+
Dir["#{Settings.source_dir}/**/*.*"]
|
93
93
|
end
|
94
94
|
|
95
95
|
def upgrade(existing_file, library_name, *args)
|
@@ -125,9 +125,6 @@ module Bashly
|
|
125
125
|
def create_user_files
|
126
126
|
quiet_say "creating user files in g`#{Settings.source_dir}`"
|
127
127
|
|
128
|
-
create_file "#{Settings.source_dir}/initialize.#{Settings.partials_extension}",
|
129
|
-
command.render(:default_initialize_script)
|
130
|
-
|
131
128
|
if command.commands.empty?
|
132
129
|
create_root_command_file
|
133
130
|
else
|
@@ -29,7 +29,7 @@ module Bashly
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
public_commands.each do |command|
|
33
33
|
result.merge! command.completion_data(with_version: false)
|
34
34
|
end
|
35
35
|
|
@@ -62,7 +62,7 @@ module Bashly
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def completion_flag_names
|
65
|
-
|
65
|
+
public_flags.map(&:name) + public_flags.map(&:short)
|
66
66
|
end
|
67
67
|
|
68
68
|
def completion_allowed_args
|
@@ -73,7 +73,7 @@ module Bashly
|
|
73
73
|
trivial_flags = %w[--help -h]
|
74
74
|
trivial_flags += %w[--version -v] if with_version
|
75
75
|
all = (
|
76
|
-
|
76
|
+
public_command_aliases + trivial_flags +
|
77
77
|
completion_flag_names + completion_allowed_args
|
78
78
|
)
|
79
79
|
|
@@ -100,14 +100,14 @@ module Bashly
|
|
100
100
|
|
101
101
|
refute value['name'].match(/^-/), "#{key}.name must not start with '-'"
|
102
102
|
|
103
|
-
refute value['required'] && value['default'], "#{key} cannot have both required and default"
|
103
|
+
refute value['required'] && value['default'], "#{key} cannot have both nub`required` and nub`default`"
|
104
104
|
end
|
105
105
|
|
106
106
|
def assert_flag(key, value)
|
107
107
|
assert_hash key, value, keys: Script::Flag.option_keys
|
108
|
-
assert value['short'] || value['long'], "#{key} must have at least one of long or short
|
108
|
+
assert value['short'] || value['long'], "#{key} must have at least one of nub`long` or nub`short`"
|
109
109
|
|
110
|
-
refute value['allowed'] && value['completions'], "#{key} cannot have both allowed and completions"
|
110
|
+
refute value['allowed'] && value['completions'], "#{key} cannot have both nub`allowed` and nub`completions`"
|
111
111
|
|
112
112
|
assert_optional_string "#{key}.long", value['long']
|
113
113
|
assert_optional_string "#{key}.short", value['short']
|
@@ -127,18 +127,18 @@ module Bashly
|
|
127
127
|
assert value['short'].match(/^-[a-zA-Z0-9]$/), "#{key}.short must be in the form of '-n'" if value['short']
|
128
128
|
refute value['arg'].match(/^-/), "#{key}.arg must not start with '-'" if value['arg']
|
129
129
|
|
130
|
-
refute value['required'] && value['default'], "#{key} cannot have both required and default"
|
130
|
+
refute value['required'] && value['default'], "#{key} cannot have both nub`required` and nub`default`"
|
131
131
|
|
132
132
|
if value['default']
|
133
|
-
assert value['arg'], "#{key}.default does not make sense without arg"
|
133
|
+
assert value['arg'], "#{key}.default does not make sense without nub`arg`"
|
134
134
|
end
|
135
135
|
|
136
136
|
if value['allowed']
|
137
|
-
assert value['arg'], "#{key}.allowed does not make sense without arg"
|
137
|
+
assert value['arg'], "#{key}.allowed does not make sense without nub`arg`"
|
138
138
|
end
|
139
139
|
|
140
140
|
if value['completions']
|
141
|
-
assert value['arg'], "#{key}.completions does not make sense without arg"
|
141
|
+
assert value['arg'], "#{key}.completions does not make sense without nub`arg`"
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
@@ -154,8 +154,8 @@ module Bashly
|
|
154
154
|
def assert_command(key, value)
|
155
155
|
assert_hash key, value, keys: Script::Command.option_keys
|
156
156
|
|
157
|
-
refute value['commands'] && value['args'], "#{key} cannot have both commands and args"
|
158
|
-
refute value['commands'] && value['catch_all'], "#{key} cannot have both commands and catch_all"
|
157
|
+
refute value['commands'] && value['args'], "#{key} cannot have both nub`commands` and nub`args`"
|
158
|
+
refute value['commands'] && value['catch_all'], "#{key} cannot have both nub`commands` and nub`catch_all`"
|
159
159
|
|
160
160
|
assert_string "#{key}.name", value['name']
|
161
161
|
assert_optional_string "#{key}.help", value['help']
|
@@ -202,7 +202,7 @@ module Bashly
|
|
202
202
|
end
|
203
203
|
|
204
204
|
if value['expose']
|
205
|
-
assert value['commands'], "#{key}.expose makes no sense without commands"
|
205
|
+
assert value['commands'], "#{key}.expose makes no sense without nub`commands`"
|
206
206
|
end
|
207
207
|
|
208
208
|
if key == 'root'
|
@@ -30,8 +30,10 @@ help:
|
|
30
30
|
handler: Bashly::Libraries::Help
|
31
31
|
|
32
32
|
hooks:
|
33
|
-
help: Add placeholders for before/after hooks which are executed before/after any command.
|
33
|
+
help: Add placeholders for initialize/before/after hooks which are executed on script initialization, and before/after any command.
|
34
34
|
files:
|
35
|
+
- source: "hooks/initialize.sh"
|
36
|
+
target: "%{user_source_dir}/initialize.%{user_ext}"
|
35
37
|
- source: "hooks/before.sh"
|
36
38
|
target: "%{user_source_dir}/before.%{user_ext}"
|
37
39
|
- source: "hooks/after.sh"
|
@@ -223,6 +223,11 @@ module Bashly
|
|
223
223
|
commands.reject(&:private)
|
224
224
|
end
|
225
225
|
|
226
|
+
# Returns a full list of the public Command names and aliases combined
|
227
|
+
def public_command_aliases
|
228
|
+
public_commands.map(&:aliases).flatten
|
229
|
+
end
|
230
|
+
|
226
231
|
# Returns only environment variables that are not private
|
227
232
|
def public_environment_variables
|
228
233
|
environment_variables.reject(&:private)
|
@@ -297,7 +302,7 @@ module Bashly
|
|
297
302
|
# This is meant to provide the user with the ability to add custom
|
298
303
|
# functions
|
299
304
|
def user_lib
|
300
|
-
@user_lib ||= Dir["#{Settings.full_lib_dir}/**/*.#{Settings.partials_extension}"]
|
305
|
+
@user_lib ||= Dir["#{Settings.full_lib_dir}/**/*.#{Settings.partials_extension}"]
|
301
306
|
end
|
302
307
|
|
303
308
|
# Returns an array of all the args with a whitelist
|
data/lib/bashly/settings.rb
CHANGED
@@ -56,9 +56,9 @@ module Bashly
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def strict_string
|
59
|
-
if
|
60
|
-
|
61
|
-
elsif
|
59
|
+
if strict.is_a? String
|
60
|
+
strict
|
61
|
+
elsif strict
|
62
62
|
'set -euo pipefail'
|
63
63
|
else
|
64
64
|
'set -e'
|
@@ -101,7 +101,13 @@ module Bashly
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def user_settings_path
|
104
|
-
ENV['BASHLY_SETTINGS_PATH']
|
104
|
+
@user_settings_path ||= if ENV['BASHLY_SETTINGS_PATH']
|
105
|
+
ENV['BASHLY_SETTINGS_PATH']
|
106
|
+
elsif File.exist? 'bashly-settings.yml'
|
107
|
+
'bashly-settings.yml'
|
108
|
+
else
|
109
|
+
'settings.yml'
|
110
|
+
end
|
105
111
|
end
|
106
112
|
|
107
113
|
def defsult_settings
|
data/lib/bashly/version.rb
CHANGED
@@ -6,7 +6,7 @@ if default_args.any? or default_flags.any?
|
|
6
6
|
end
|
7
7
|
|
8
8
|
default_flags.each do |flag|
|
9
|
-
> [[ -n ${args['{{ flag.
|
9
|
+
> [[ -n ${args['{{ flag.name }}']:-} ]] || args['{{ flag.name }}']="{{ flag.default }}"
|
10
10
|
end
|
11
11
|
|
12
12
|
>
|
@@ -4,13 +4,16 @@
|
|
4
4
|
> version="<%= version %>"
|
5
5
|
> long_usage=''
|
6
6
|
> {{ Settings.strict_string }}
|
7
|
-
>
|
8
7
|
|
9
8
|
if root_command?
|
9
|
+
>
|
10
10
|
= render(:environment_variables_default).indent 2
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
if user_file_exist?('initialize')
|
14
|
+
>
|
15
|
+
= load_user_file('initialize').indent 2
|
16
|
+
end
|
14
17
|
|
15
18
|
> }
|
16
19
|
>
|
@@ -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.
|
5
|
+
> if [[ -z ${args['{{ flag.name }}']+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 [[ -n ${args['{{ arg.name }}']} ]] && [[ ! ${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 }}']} ]] && [[ ! ${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
|
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.0.
|
4
|
+
version: 1.0.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: 2023-
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/bashly/libraries/help/help_command.sh
|
158
158
|
- lib/bashly/libraries/hooks/after.sh
|
159
159
|
- lib/bashly/libraries/hooks/before.sh
|
160
|
+
- lib/bashly/libraries/hooks/initialize.sh
|
160
161
|
- lib/bashly/libraries/lib/sample_function.sh
|
161
162
|
- lib/bashly/libraries/libraries.yml
|
162
163
|
- lib/bashly/libraries/settings/settings.yml
|
@@ -192,7 +193,6 @@ files:
|
|
192
193
|
- lib/bashly/views/command/command_filter.gtx
|
193
194
|
- lib/bashly/views/command/command_functions.gtx
|
194
195
|
- lib/bashly/views/command/default_assignments.gtx
|
195
|
-
- lib/bashly/views/command/default_initialize_script.gtx
|
196
196
|
- lib/bashly/views/command/default_root_script.gtx
|
197
197
|
- lib/bashly/views/command/default_script.gtx
|
198
198
|
- lib/bashly/views/command/dependencies_filter.gtx
|
@@ -255,14 +255,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
255
255
|
requirements:
|
256
256
|
- - ">="
|
257
257
|
- !ruby/object:Gem::Version
|
258
|
-
version:
|
258
|
+
version: '3.0'
|
259
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
260
260
|
requirements:
|
261
261
|
- - ">="
|
262
262
|
- !ruby/object:Gem::Version
|
263
263
|
version: '0'
|
264
264
|
requirements: []
|
265
|
-
rubygems_version: 3.
|
265
|
+
rubygems_version: 3.3.26
|
266
266
|
signing_key:
|
267
267
|
specification_version: 4
|
268
268
|
summary: Bash Command Line Tool Generator
|