bashly 0.6.9 → 0.7.3
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/add.rb +29 -88
- data/lib/bashly/commands/generate.rb +51 -10
- data/lib/bashly/commands/init.rb +1 -1
- data/lib/bashly/commands/preview.rb +2 -2
- data/lib/bashly/commands/validate.rb +19 -0
- data/lib/bashly/concerns/asset_helper.rb +4 -0
- data/lib/bashly/concerns/command_scopes.rb +68 -0
- data/lib/bashly/config_validator.rb +142 -0
- data/lib/bashly/extensions/file.rb +13 -0
- data/lib/bashly/extensions/string.rb +5 -1
- data/lib/bashly/libraries/base.rb +19 -0
- data/lib/bashly/libraries/completions.rb +14 -0
- data/lib/bashly/libraries/completions_function.rb +38 -0
- data/lib/bashly/libraries/completions_script.rb +29 -0
- data/lib/bashly/libraries/completions_yaml.rb +27 -0
- data/lib/bashly/libraries.yml +39 -0
- data/lib/bashly/library.rb +63 -0
- data/lib/bashly/refinements/compose_refinements.rb +45 -0
- data/lib/bashly/{models → script}/argument.rb +1 -1
- data/lib/bashly/{models → script}/base.rb +5 -4
- data/lib/bashly/script/catch_all.rb +49 -0
- data/lib/bashly/{models → script}/command.rb +10 -112
- data/lib/bashly/{models → script}/environment_variable.rb +1 -1
- data/lib/bashly/{models → script}/flag.rb +1 -1
- data/lib/bashly/{models/script.rb → script/wrapper.rb} +2 -2
- data/lib/bashly/templates/lib/colors.sh +12 -15
- data/lib/bashly/templates/lib/config.sh +34 -35
- data/lib/bashly/templates/lib/sample_function.sh +10 -10
- data/lib/bashly/templates/lib/validations/validate_dir_exists.sh +1 -0
- data/lib/bashly/templates/lib/validations/validate_file_exists.sh +1 -0
- data/lib/bashly/templates/lib/validations/validate_integer.sh +1 -0
- data/lib/bashly/templates/lib/validations/validate_not_empty.sh +1 -0
- data/lib/bashly/templates/lib/yaml.sh +12 -15
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/catch_all_filter.erb +2 -2
- data/lib/bashly/views/command/command_filter.erb +1 -1
- data/lib/bashly/views/command/default_assignments.erb +2 -2
- data/lib/bashly/views/command/default_initialize_script.erb +6 -6
- data/lib/bashly/views/command/default_root_script.erb +1 -1
- data/lib/bashly/views/command/environment_variables_filter.erb +1 -1
- data/lib/bashly/views/command/fixed_flags_filter.erb +1 -1
- data/lib/bashly/views/command/initialize.erb +1 -1
- data/lib/bashly/views/command/parse_requirements.erb +1 -1
- data/lib/bashly/views/command/parse_requirements_case.erb +2 -2
- data/lib/bashly/views/command/parse_requirements_while.erb +2 -2
- data/lib/bashly/views/command/required_args_filter.erb +1 -6
- data/lib/bashly/views/command/required_flags_filter.erb +1 -4
- data/lib/bashly/views/command/root_command.erb +1 -1
- data/lib/bashly/views/command/run.erb +4 -4
- data/lib/bashly/views/command/usage.erb +1 -1
- data/lib/bashly/views/command/usage_args.erb +3 -3
- data/lib/bashly/views/command/usage_commands.erb +1 -1
- data/lib/bashly/views/{script → wrapper}/bash3_bouncer.erb +0 -0
- data/lib/bashly/views/{script → wrapper}/header.erb +0 -0
- data/lib/bashly/views/{script → wrapper}/wrapper.erb +0 -0
- data/lib/bashly.rb +3 -1
- metadata +27 -14
@@ -1,18 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#
|
14
|
-
# ---
|
15
|
-
|
1
|
+
## YAML parser [@bashly-upgrade yaml]
|
2
|
+
## This file is a part of Bashly standard library
|
3
|
+
## Does not support arrays, only hashes
|
4
|
+
##
|
5
|
+
## Source: https://stackoverflow.com/a/21189044/413924
|
6
|
+
##
|
7
|
+
## Usage:
|
8
|
+
##
|
9
|
+
## yaml_load "settings.yml" # print variables
|
10
|
+
## yaml_load "settings.yml" "config_" # use prefix
|
11
|
+
## eval $(yaml_load "settings.yml") # create variables in scope
|
12
|
+
##
|
16
13
|
yaml_load() {
|
17
14
|
local prefix=$2
|
18
15
|
local s='[[:space:]]*' w='[a-zA-Z0-9_]*'
|
data/lib/bashly/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# :command.catch_all_filter
|
2
|
-
% if
|
2
|
+
% if catch_all.required?
|
3
3
|
if [[ ${#other_args[@]} -eq 0 ]]; then
|
4
|
-
printf "<%= strings[:missing_required_argument] % { arg:
|
4
|
+
printf "<%= strings[:missing_required_argument] % { arg: catch_all.label, usage: usage_string } %>\n"
|
5
5
|
exit 1
|
6
6
|
fi
|
7
7
|
% end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# :command.default_assignments
|
2
2
|
% default_args.each do |arg|
|
3
|
-
[[ -n ${args[<%= arg.name %>]} ]] || args[<%= arg.name %>]="<%= arg.default %>"
|
3
|
+
[[ -n ${args[<%= arg.name %>]:-} ]] || args[<%= arg.name %>]="<%= arg.default %>"
|
4
4
|
% end
|
5
5
|
% default_flags.each do |flag|
|
6
|
-
[[ -n ${args[<%= flag.long %>]} ]] || args[<%= flag.long %>]="<%= flag.default %>"
|
6
|
+
[[ -n ${args[<%= flag.long %>]:-} ]] || args[<%= flag.long %>]="<%= flag.default %>"
|
7
7
|
% end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
## Code here runs inside the initialize() function
|
2
|
+
## Use it for anything that you need to run before any other function, like
|
3
|
+
## setting environment vairables:
|
4
|
+
## CONFIG_FILE=settings.ini
|
5
|
+
##
|
6
|
+
## Feel free to empty (but not delete) this file.
|
@@ -6,7 +6,7 @@ export <%= env_var.name.upcase %>="${<%= env_var.name.upcase %>:-<%= env_var.def
|
|
6
6
|
% end
|
7
7
|
% if required_environment_variables.any?
|
8
8
|
% required_environment_variables.each do |env_var|
|
9
|
-
if [[ -z "
|
9
|
+
if [[ -z "${<%= env_var.name.upcase %>:-}" ]]; then
|
10
10
|
printf "<%= strings[:missing_required_environment_variable] % { var: env_var.name.upcase } %>\n"
|
11
11
|
exit 1
|
12
12
|
fi
|
@@ -8,9 +8,9 @@ parse_requirements() {
|
|
8
8
|
<%= render(:environment_variables_filter).indent 2 %>
|
9
9
|
<%= render(:dependencies_filter).indent 2 %>
|
10
10
|
<%= render(:command_filter).indent 2 %>
|
11
|
+
<%= render(:parse_requirements_while).indent 2 %>
|
11
12
|
<%= render(:required_args_filter).indent 2 %>
|
12
13
|
<%= render(:required_flags_filter).indent 2 %>
|
13
|
-
<%= render(:parse_requirements_while).indent 2 %>
|
14
14
|
<%= render(:catch_all_filter).indent 2 %>
|
15
15
|
<%= render(:default_assignments).indent 2 %>
|
16
16
|
<%= render(:whitelist_filter).indent 2 %>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
% condition = "elif"
|
10
10
|
% end
|
11
11
|
else
|
12
|
-
% if catch_all
|
12
|
+
% if catch_all.enabled?
|
13
13
|
other_args+=("$1")
|
14
14
|
shift
|
15
15
|
% else
|
@@ -17,7 +17,7 @@ else
|
|
17
17
|
exit 1
|
18
18
|
% end
|
19
19
|
fi
|
20
|
-
% elsif catch_all
|
20
|
+
% elsif catch_all.enabled?
|
21
21
|
other_args+=("$1")
|
22
22
|
shift
|
23
23
|
% else
|
@@ -1,12 +1,7 @@
|
|
1
1
|
# :command.required_args_filter
|
2
2
|
% required_args.each do |arg|
|
3
|
-
if [[ -
|
4
|
-
<%= arg.render(:validations).indent 2 %>
|
5
|
-
args[<%= arg.name %>]=$1
|
6
|
-
shift
|
7
|
-
else
|
3
|
+
if [[ -z ${args[<%= arg.name %>]+x} ]]; then
|
8
4
|
printf "<%= strings[:missing_required_argument] % { arg: arg.name.upcase, usage: usage_string } %>\n"
|
9
5
|
exit 1
|
10
6
|
fi
|
11
|
-
|
12
7
|
% end
|
@@ -1,9 +1,6 @@
|
|
1
1
|
# :command.required_flags_filter
|
2
|
-
% if required_flags.any?
|
3
|
-
argstring="$*"
|
4
|
-
% end
|
5
2
|
% required_flags.each do |flag|
|
6
|
-
if [[ <%= flag.
|
3
|
+
if [[ -z ${args[<%= flag.long %>]+x} ]]; then
|
7
4
|
printf "<%= strings[:missing_required_flag] % { usage: flag.usage_string } %>\n"
|
8
5
|
exit 1
|
9
6
|
fi
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# :command.run
|
2
2
|
run() {
|
3
|
-
declare -A args
|
4
|
-
declare -a other_args
|
5
|
-
declare -a input
|
3
|
+
declare -A args=()
|
4
|
+
declare -a other_args=()
|
5
|
+
declare -a input=()
|
6
6
|
normalize_input "$@"
|
7
7
|
parse_requirements "${input[@]}"
|
8
8
|
|
9
9
|
<%- condition = "if" -%>
|
10
10
|
<%- deep_commands.each do |command| -%>
|
11
11
|
<%= condition %> [[ $action == "<%= command.action_name %>" ]]; then
|
12
|
-
if [[ ${args[--help]} ]]; then
|
12
|
+
if [[ ${args[--help]:-} ]]; then
|
13
13
|
long_usage=yes
|
14
14
|
<%= command.function_name %>_usage
|
15
15
|
else
|
@@ -37,7 +37,7 @@
|
|
37
37
|
printf "<%= strings[:options] %>\n"
|
38
38
|
<%= render(:usage_fixed_flags).indent 4 %>
|
39
39
|
<%= render(:usage_flags).indent 4 if flags.any? %>
|
40
|
-
<%= render(:usage_args).indent 4 if args.any? or
|
40
|
+
<%= render(:usage_args).indent 4 if args.any? or catch_all.help %>
|
41
41
|
<%= render(:usage_environment_variables).indent 4 if environment_variables.any? %>
|
42
42
|
<%= render(:usage_examples).indent 4 if examples %>
|
43
43
|
<%= render(:footer).indent 4 if footer %>
|
@@ -6,9 +6,9 @@ printf "<%= strings[:arguments] %>\n"
|
|
6
6
|
<%= arg.render(:usage) %>
|
7
7
|
% end
|
8
8
|
% end
|
9
|
-
% if
|
9
|
+
% if catch_all.help
|
10
10
|
|
11
|
-
echo " <%=
|
12
|
-
printf "<%=
|
11
|
+
echo " <%= catch_all.label %>"
|
12
|
+
printf "<%= catch_all.help.wrap(76).indent(4).sanitize_for_print %>\n"
|
13
13
|
echo
|
14
14
|
% end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
printf "<%= strings[:commands] %>\n"
|
4
4
|
% end
|
5
5
|
% maxlen = command_names.map(&:size).max
|
6
|
-
% commands.each do |command|
|
6
|
+
% commands.reject(&:private).each do |command|
|
7
7
|
% summary = command.summary
|
8
8
|
% summary = strings[:default_command_summary] % { summary: summary } if command.default
|
9
9
|
% if command.group
|
File without changes
|
File without changes
|
File without changes
|
data/lib/bashly.rb
CHANGED
@@ -9,6 +9,8 @@ requires 'bashly/concerns'
|
|
9
9
|
|
10
10
|
requires 'bashly/settings'
|
11
11
|
requires 'bashly/exceptions'
|
12
|
-
requires 'bashly/
|
12
|
+
requires 'bashly/refinements'
|
13
|
+
requires 'bashly/script/base'
|
13
14
|
requires 'bashly/commands/base'
|
15
|
+
requires 'bashly/libraries/base'
|
14
16
|
requires 'bashly'
|
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.
|
4
|
+
version: 0.7.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:
|
11
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mister_bin
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,20 +82,33 @@ files:
|
|
82
82
|
- lib/bashly/commands/generate.rb
|
83
83
|
- lib/bashly/commands/init.rb
|
84
84
|
- lib/bashly/commands/preview.rb
|
85
|
+
- lib/bashly/commands/validate.rb
|
85
86
|
- lib/bashly/concerns/asset_helper.rb
|
87
|
+
- lib/bashly/concerns/command_scopes.rb
|
86
88
|
- lib/bashly/concerns/completions.rb
|
87
89
|
- lib/bashly/concerns/renderable.rb
|
88
90
|
- lib/bashly/config.rb
|
91
|
+
- lib/bashly/config_validator.rb
|
89
92
|
- lib/bashly/exceptions.rb
|
90
93
|
- lib/bashly/extensions/array.rb
|
94
|
+
- lib/bashly/extensions/file.rb
|
91
95
|
- lib/bashly/extensions/string.rb
|
96
|
+
- lib/bashly/libraries.yml
|
97
|
+
- lib/bashly/libraries/base.rb
|
98
|
+
- lib/bashly/libraries/completions.rb
|
99
|
+
- lib/bashly/libraries/completions_function.rb
|
100
|
+
- lib/bashly/libraries/completions_script.rb
|
101
|
+
- lib/bashly/libraries/completions_yaml.rb
|
102
|
+
- lib/bashly/library.rb
|
92
103
|
- lib/bashly/message_strings.rb
|
93
|
-
- lib/bashly/
|
94
|
-
- lib/bashly/
|
95
|
-
- lib/bashly/
|
96
|
-
- lib/bashly/
|
97
|
-
- lib/bashly/
|
98
|
-
- lib/bashly/
|
104
|
+
- lib/bashly/refinements/compose_refinements.rb
|
105
|
+
- lib/bashly/script/argument.rb
|
106
|
+
- lib/bashly/script/base.rb
|
107
|
+
- lib/bashly/script/catch_all.rb
|
108
|
+
- lib/bashly/script/command.rb
|
109
|
+
- lib/bashly/script/environment_variable.rb
|
110
|
+
- lib/bashly/script/flag.rb
|
111
|
+
- lib/bashly/script/wrapper.rb
|
99
112
|
- lib/bashly/settings.rb
|
100
113
|
- lib/bashly/templates/bashly.yml
|
101
114
|
- lib/bashly/templates/lib/colors.sh
|
@@ -149,9 +162,9 @@ files:
|
|
149
162
|
- lib/bashly/views/flag/case.erb
|
150
163
|
- lib/bashly/views/flag/usage.erb
|
151
164
|
- lib/bashly/views/flag/validations.erb
|
152
|
-
- lib/bashly/views/
|
153
|
-
- lib/bashly/views/
|
154
|
-
- lib/bashly/views/
|
165
|
+
- lib/bashly/views/wrapper/bash3_bouncer.erb
|
166
|
+
- lib/bashly/views/wrapper/header.erb
|
167
|
+
- lib/bashly/views/wrapper/wrapper.erb
|
155
168
|
homepage: https://github.com/dannyben/bashly
|
156
169
|
licenses:
|
157
170
|
- MIT
|
@@ -175,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
188
|
- !ruby/object:Gem::Version
|
176
189
|
version: '0'
|
177
190
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.3.6
|
179
192
|
signing_key:
|
180
193
|
specification_version: 4
|
181
194
|
summary: Bash Command Line Tool Generator
|