bashly 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bashly/commands/add.rb +5 -2
- data/lib/bashly/commands/generate.rb +2 -1
- data/lib/bashly/config_validator.rb +7 -5
- data/lib/bashly/libraries/completions_function.rb +1 -1
- data/lib/bashly/libraries/help.rb +1 -1
- data/lib/bashly/libraries.yml +8 -8
- data/lib/bashly/library.rb +1 -0
- data/lib/bashly/script/command.rb +2 -2
- data/lib/bashly/script/wrapper.rb +1 -1
- data/lib/bashly/settings.rb +26 -22
- data/lib/bashly/templates/settings.yml +3 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/command_fallback.gtx +8 -5
- data/lib/bashly/views/command/command_filter.gtx +1 -2
- data/lib/bashly/views/command/dependencies_filter.gtx +1 -2
- data/lib/bashly/views/command/run.gtx +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1139c7453fff329c05879511103b80b6a89a76896a9d0cb3f5cad016d224b15
|
4
|
+
data.tar.gz: acda8a068081a04a32218be7ddfee8cad1612b3dfafd9e1465170fd9cded32db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61247ecd7b928a4babdbf307004424ffa060c567a16b4eb4b062c59e51eb9812f3469981ead958bb4f08aee8cb7ecd86a32a830f6102211012540eac0b878fd4
|
7
|
+
data.tar.gz: 606e5df99d98e9853ed25a7fd516a807a90f1c40d7f19ac2ab1b8f3388a82919dd59af3b291d8de7b866d88cdcb8b1fec7883bd258b80c04f137b1729e58aca1
|
data/lib/bashly/commands/add.rb
CHANGED
@@ -34,8 +34,11 @@ module Bashly
|
|
34
34
|
command 'comp', 'Generate a bash completions script or function.'
|
35
35
|
command 'config', 'Add standard functions for handling INI files to the lib directory.'
|
36
36
|
command 'help', 'Add a help command, in addition to the standard --help flag.'
|
37
|
-
command 'lib',
|
38
|
-
|
37
|
+
command 'lib', <<~USAGE
|
38
|
+
Create the lib directory for any additional user scripts.
|
39
|
+
All *.sh scripts in this directory will be included in the final bash script.
|
40
|
+
Note that if you configured a different partials_extension, then the extensions of the files in this directory need to match.
|
41
|
+
USAGE
|
39
42
|
|
40
43
|
command 'settings', 'Copy a sample settings.yml file to your project, allowing you to customize some ' \
|
41
44
|
'bashly options.'
|
@@ -130,7 +130,8 @@ module Bashly
|
|
130
130
|
def create_user_files
|
131
131
|
quiet_say "creating user files in !txtgrn!#{Settings.source_dir}"
|
132
132
|
|
133
|
-
create_file "#{Settings.source_dir}/initialize.
|
133
|
+
create_file "#{Settings.source_dir}/initialize.#{Settings.partials_extension}",
|
134
|
+
command.render(:default_initialize_script)
|
134
135
|
|
135
136
|
if command.commands.empty?
|
136
137
|
create_root_command_file
|
@@ -37,6 +37,12 @@ module Bashly
|
|
37
37
|
assert_boolean "#{key}.required", value['required']
|
38
38
|
end
|
39
39
|
|
40
|
+
def assert_default_command(key, value)
|
41
|
+
return unless value
|
42
|
+
|
43
|
+
assert [true, false, nil, 'force'].include?(value), "#{key} must be a boolean, or the string 'force'"
|
44
|
+
end
|
45
|
+
|
40
46
|
def assert_dependencies(key, value)
|
41
47
|
return unless value
|
42
48
|
|
@@ -145,7 +151,7 @@ module Bashly
|
|
145
151
|
assert_optional_string "#{key}.function", value['function']
|
146
152
|
|
147
153
|
assert_boolean "#{key}.private", value['private']
|
148
|
-
|
154
|
+
assert_default_command "#{key}.default", value['default']
|
149
155
|
assert_expose "#{key}.expose", value['expose']
|
150
156
|
assert_version "#{key}.version", value['version']
|
151
157
|
assert_catch_all "#{key}.catch_all", value['catch_all']
|
@@ -171,10 +177,6 @@ module Bashly
|
|
171
177
|
"#{key}.function must contain lowercase alphanumeric characters and underscores only"
|
172
178
|
end
|
173
179
|
|
174
|
-
if value['default']
|
175
|
-
assert value['args'], "#{key}.default makes no sense without args"
|
176
|
-
end
|
177
|
-
|
178
180
|
if value['catch_all'] && value['args']
|
179
181
|
repeatable_arg = value['args'].find { |a| a['repeatable'] }&.dig 'name'
|
180
182
|
refute repeatable_arg, "#{key}.catch_all makes no sense with repeatable arg (#{repeatable_arg})"
|
data/lib/bashly/libraries.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
colors:
|
2
2
|
files:
|
3
3
|
- source: "templates/lib/colors.sh"
|
4
|
-
target: "%{user_lib_dir}/colors
|
4
|
+
target: "%{user_lib_dir}/colors.%{user_ext}"
|
5
5
|
|
6
6
|
completions: :CompletionsFunction
|
7
7
|
completions_script: :CompletionsScript
|
@@ -10,14 +10,14 @@ completions_yaml: :CompletionsYAML
|
|
10
10
|
config:
|
11
11
|
files:
|
12
12
|
- source: "templates/lib/config.sh"
|
13
|
-
target: "%{user_lib_dir}/config
|
13
|
+
target: "%{user_lib_dir}/config.%{user_ext}"
|
14
14
|
|
15
15
|
help: :Help
|
16
16
|
|
17
17
|
lib:
|
18
18
|
files:
|
19
19
|
- source: "templates/lib/sample_function.sh"
|
20
|
-
target: "%{user_lib_dir}/sample_function
|
20
|
+
target: "%{user_lib_dir}/sample_function.%{user_ext}"
|
21
21
|
|
22
22
|
settings:
|
23
23
|
files:
|
@@ -46,15 +46,15 @@ test:
|
|
46
46
|
validations:
|
47
47
|
files:
|
48
48
|
- source: "templates/lib/validations/validate_dir_exists.sh"
|
49
|
-
target: "%{user_lib_dir}/validations/validate_dir_exists
|
49
|
+
target: "%{user_lib_dir}/validations/validate_dir_exists.%{user_ext}"
|
50
50
|
- source: "templates/lib/validations/validate_file_exists.sh"
|
51
|
-
target: "%{user_lib_dir}/validations/validate_file_exists
|
51
|
+
target: "%{user_lib_dir}/validations/validate_file_exists.%{user_ext}"
|
52
52
|
- source: "templates/lib/validations/validate_integer.sh"
|
53
|
-
target: "%{user_lib_dir}/validations/validate_integer
|
53
|
+
target: "%{user_lib_dir}/validations/validate_integer.%{user_ext}"
|
54
54
|
- source: "templates/lib/validations/validate_not_empty.sh"
|
55
|
-
target: "%{user_lib_dir}/validations/validate_not_empty
|
55
|
+
target: "%{user_lib_dir}/validations/validate_not_empty.%{user_ext}"
|
56
56
|
|
57
57
|
yaml:
|
58
58
|
files:
|
59
59
|
- source: "templates/lib/yaml.sh"
|
60
|
-
target: "%{user_lib_dir}/yaml
|
60
|
+
target: "%{user_lib_dir}/yaml.%{user_ext}"
|
data/lib/bashly/library.rb
CHANGED
@@ -156,7 +156,7 @@ module Bashly
|
|
156
156
|
# Returns the bash filename that is expected to hold the user code
|
157
157
|
# for this command
|
158
158
|
def filename
|
159
|
-
options['filename'] || "#{action_name.to_underscore}_command.
|
159
|
+
options['filename'] || "#{action_name.to_underscore}_command.#{Settings.partials_extension}"
|
160
160
|
end
|
161
161
|
|
162
162
|
# Returns an array of Flags
|
@@ -281,7 +281,7 @@ module Bashly
|
|
281
281
|
# This is meant to provide the user with the ability to add custom
|
282
282
|
# functions
|
283
283
|
def user_lib
|
284
|
-
@user_lib ||= Dir["#{Settings.full_lib_dir}
|
284
|
+
@user_lib ||= Dir["#{Settings.full_lib_dir}/**/*.#{Settings.partials_extension}"].sort
|
285
285
|
end
|
286
286
|
|
287
287
|
# Returns an array of all the args with a whitelist
|
data/lib/bashly/settings.rb
CHANGED
@@ -3,47 +3,51 @@ module Bashly
|
|
3
3
|
class << self
|
4
4
|
include AssetHelper
|
5
5
|
|
6
|
-
attr_writer :compact_short_flags, :
|
7
|
-
:
|
6
|
+
attr_writer :compact_short_flags, :lib_dir, :partials_extension,
|
7
|
+
:source_dir, :strict, :tab_indent, :target_dir
|
8
8
|
|
9
|
-
def
|
10
|
-
@
|
9
|
+
def compact_short_flags
|
10
|
+
@compact_short_flags ||= get :compact_short_flags
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
@
|
13
|
+
def env
|
14
|
+
@env ||= get(:env)&.to_sym
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
@
|
17
|
+
def env=(value)
|
18
|
+
@env = value&.to_sym
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
21
|
+
def full_lib_dir
|
22
|
+
"#{source_dir}/#{lib_dir}"
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
@
|
25
|
+
def lib_dir
|
26
|
+
@lib_dir ||= get :lib_dir
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
@
|
29
|
+
def partials_extension
|
30
|
+
@partials_extension ||= get :partials_extension
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
|
33
|
+
def production?
|
34
|
+
env == :production
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
@
|
37
|
+
def source_dir
|
38
|
+
@source_dir ||= get :source_dir
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
|
41
|
+
def strict
|
42
|
+
@strict ||= get :strict
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
45
|
+
def tab_indent
|
46
|
+
@tab_indent ||= get :tab_indent
|
47
|
+
end
|
48
|
+
|
49
|
+
def target_dir
|
50
|
+
@target_dir ||= get :target_dir
|
47
51
|
end
|
48
52
|
|
49
53
|
private
|
data/lib/bashly/version.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
= view_marker
|
2
2
|
|
3
|
-
|
4
|
-
>
|
5
|
-
>
|
6
|
-
>
|
7
|
-
>
|
3
|
+
if !default_command || default_command.default != 'force'
|
4
|
+
> "")
|
5
|
+
> {{ function_name }}_usage >&2
|
6
|
+
> exit 1
|
7
|
+
> ;;
|
8
|
+
>
|
9
|
+
end
|
10
|
+
|
8
11
|
> *)
|
9
12
|
|
10
13
|
if default_command
|
@@ -5,8 +5,7 @@ if dependencies
|
|
5
5
|
> if ! command -v {{ dependency }} >/dev/null 2>&1; then
|
6
6
|
> printf "{{ strings[:missing_dependency] % { dependency: dependency } }}\n" >&2
|
7
7
|
if message and !message.empty?
|
8
|
-
>
|
9
|
-
> printf "{{ message }}\n" >&2
|
8
|
+
> printf "%s\n" "{{ message }}" >&2
|
10
9
|
end
|
11
10
|
> exit 1
|
12
11
|
> 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.1
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: completely
|