bashly 0.8.1 → 0.8.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/commands/generate.rb +40 -4
- data/lib/bashly/concerns/renderable.rb +19 -6
- data/lib/bashly/config_validator.rb +11 -0
- data/lib/bashly/extensions/string.rb +2 -2
- data/lib/bashly/script/command.rb +126 -24
- data/lib/bashly/templates/strings.yml +1 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/README.md +6 -0
- data/lib/bashly/views/argument/usage.gtx +15 -0
- data/lib/bashly/views/argument/validations.gtx +11 -0
- data/lib/bashly/views/command/catch_all_filter.gtx +10 -0
- data/lib/bashly/views/command/command_fallback.gtx +42 -0
- data/lib/bashly/views/command/command_filter.gtx +29 -0
- data/lib/bashly/views/command/command_functions.gtx +5 -0
- data/lib/bashly/views/command/default_assignments.gtx +13 -0
- data/lib/bashly/views/command/default_initialize_script.gtx +7 -0
- data/lib/bashly/views/command/default_root_script.gtx +4 -0
- data/lib/bashly/views/command/default_script.gtx +5 -0
- data/lib/bashly/views/command/dependencies_filter.gtx +10 -0
- data/lib/bashly/views/command/environment_variables_filter.gtx +18 -0
- data/lib/bashly/views/command/fixed_flags_filter.gtx +20 -0
- data/lib/bashly/views/command/footer.gtx +5 -0
- data/lib/bashly/views/command/function.gtx +6 -0
- data/lib/bashly/views/command/initialize.gtx +12 -0
- data/lib/bashly/views/command/inspect_args.gtx +21 -0
- data/lib/bashly/views/command/long_usage.gtx +13 -0
- data/lib/bashly/views/command/master_script.gtx +17 -0
- data/lib/bashly/views/command/normalize_input.gtx +25 -0
- data/lib/bashly/views/command/parse_requirements.gtx +26 -0
- data/lib/bashly/views/command/parse_requirements_case.gtx +11 -0
- data/lib/bashly/views/command/parse_requirements_case_catch_all.gtx +23 -0
- data/lib/bashly/views/command/parse_requirements_case_repeatable.gtx +24 -0
- data/lib/bashly/views/command/parse_requirements_case_simple.gtx +25 -0
- data/lib/bashly/views/command/parse_requirements_while.gtx +33 -0
- data/lib/bashly/views/command/required_args_filter.gtx +13 -0
- data/lib/bashly/views/command/required_flags_filter.gtx +12 -0
- data/lib/bashly/views/command/root_command.gtx +6 -0
- data/lib/bashly/views/command/run.gtx +28 -0
- data/lib/bashly/views/command/usage.gtx +50 -0
- data/lib/bashly/views/command/usage_args.gtx +20 -0
- data/lib/bashly/views/command/usage_commands.gtx +18 -0
- data/lib/bashly/views/command/usage_environment_variables.gtx +10 -0
- data/lib/bashly/views/command/usage_examples.gtx +10 -0
- data/lib/bashly/views/command/usage_fixed_flags.gtx +13 -0
- data/lib/bashly/views/command/usage_flags.gtx +7 -0
- data/lib/bashly/views/command/user_filter.gtx +13 -0
- data/lib/bashly/views/command/user_lib.gtx +11 -0
- data/lib/bashly/views/command/version_command.gtx +6 -0
- data/lib/bashly/views/command/whitelist_filter.gtx +41 -0
- data/lib/bashly/views/environment_variable/usage.gtx +11 -0
- data/lib/bashly/views/flag/case.gtx +6 -0
- data/lib/bashly/views/flag/case_arg.gtx +25 -0
- data/lib/bashly/views/flag/case_no_arg.gtx +11 -0
- data/lib/bashly/views/flag/conflicts.gtx +22 -0
- data/lib/bashly/views/flag/usage.gtx +15 -0
- data/lib/bashly/views/flag/validations.gtx +11 -0
- data/lib/bashly/views/wrapper/bash3_bouncer.gtx +7 -0
- data/lib/bashly/views/wrapper/header.gtx +5 -0
- data/lib/bashly/views/wrapper/wrapper.gtx +8 -0
- metadata +89 -60
- data/lib/bashly/concerns/command_scopes.rb +0 -83
- data/lib/bashly/views/argument/usage.erb +0 -10
- data/lib/bashly/views/argument/validations.erb +0 -8
- data/lib/bashly/views/command/catch_all_filter.erb +0 -7
- data/lib/bashly/views/command/command_fallback.erb +0 -45
- data/lib/bashly/views/command/command_filter.erb +0 -22
- data/lib/bashly/views/command/command_functions.erb +0 -4
- data/lib/bashly/views/command/default_assignments.erb +0 -7
- data/lib/bashly/views/command/default_initialize_script.erb +0 -6
- data/lib/bashly/views/command/default_root_script.erb +0 -3
- data/lib/bashly/views/command/default_script.erb +0 -4
- data/lib/bashly/views/command/dependencies_filter.erb +0 -9
- data/lib/bashly/views/command/environment_variables_filter.erb +0 -14
- data/lib/bashly/views/command/fixed_flags_filter.erb +0 -24
- data/lib/bashly/views/command/footer.erb +0 -3
- data/lib/bashly/views/command/function.erb +0 -4
- data/lib/bashly/views/command/initialize.erb +0 -8
- data/lib/bashly/views/command/inspect_args.erb +0 -19
- data/lib/bashly/views/command/master_script.erb +0 -14
- data/lib/bashly/views/command/normalize_input.erb +0 -24
- data/lib/bashly/views/command/parse_requirements.erb +0 -22
- data/lib/bashly/views/command/parse_requirements_case.erb +0 -8
- data/lib/bashly/views/command/parse_requirements_case_catch_all.erb +0 -18
- data/lib/bashly/views/command/parse_requirements_case_repeatable.erb +0 -18
- data/lib/bashly/views/command/parse_requirements_case_simple.erb +0 -18
- data/lib/bashly/views/command/parse_requirements_while.erb +0 -26
- data/lib/bashly/views/command/required_args_filter.erb +0 -7
- data/lib/bashly/views/command/required_flags_filter.erb +0 -7
- data/lib/bashly/views/command/root_command.erb +0 -4
- data/lib/bashly/views/command/run.erb +0 -23
- data/lib/bashly/views/command/usage.erb +0 -50
- data/lib/bashly/views/command/usage_args.erb +0 -14
- data/lib/bashly/views/command/usage_commands.erb +0 -18
- data/lib/bashly/views/command/usage_environment_variables.erb +0 -6
- data/lib/bashly/views/command/usage_examples.erb +0 -7
- data/lib/bashly/views/command/usage_fixed_flags.erb +0 -17
- data/lib/bashly/views/command/usage_flags.erb +0 -4
- data/lib/bashly/views/command/user_filter.erb +0 -11
- data/lib/bashly/views/command/user_lib.erb +0 -6
- data/lib/bashly/views/command/version_command.erb +0 -4
- data/lib/bashly/views/command/whitelist_filter.erb +0 -33
- data/lib/bashly/views/environment_variable/usage.erb +0 -7
- data/lib/bashly/views/flag/case.erb +0 -4
- data/lib/bashly/views/flag/case_arg.erb +0 -19
- data/lib/bashly/views/flag/case_no_arg.erb +0 -8
- data/lib/bashly/views/flag/conflicts.erb +0 -18
- data/lib/bashly/views/flag/usage.erb +0 -10
- data/lib/bashly/views/flag/validations.erb +0 -8
- data/lib/bashly/views/wrapper/bash3_bouncer.erb +0 -5
- data/lib/bashly/views/wrapper/header.erb +0 -4
- data/lib/bashly/views/wrapper/wrapper.erb +0 -6
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bashly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.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-
|
11
|
+
date: 2022-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: completely
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: gtx
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colsole
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
47
|
+
version: '0.7'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
54
|
+
version: '0.7'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: mister_bin
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: filewatcher
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.1'
|
69
97
|
description: Generate bash command line tools using YAML configuration
|
70
98
|
email: db@dannyben.com
|
71
99
|
executables:
|
@@ -84,7 +112,6 @@ files:
|
|
84
112
|
- lib/bashly/commands/preview.rb
|
85
113
|
- lib/bashly/commands/validate.rb
|
86
114
|
- lib/bashly/concerns/asset_helper.rb
|
87
|
-
- lib/bashly/concerns/command_scopes.rb
|
88
115
|
- lib/bashly/concerns/completions.rb
|
89
116
|
- lib/bashly/concerns/renderable.rb
|
90
117
|
- lib/bashly/concerns/validation_helpers.rb
|
@@ -127,56 +154,58 @@ files:
|
|
127
154
|
- lib/bashly/templates/strings.yml
|
128
155
|
- lib/bashly/templates/test/approvals.bash
|
129
156
|
- lib/bashly/version.rb
|
130
|
-
- lib/bashly/views/
|
131
|
-
- lib/bashly/views/argument/
|
132
|
-
- lib/bashly/views/
|
133
|
-
- lib/bashly/views/command/
|
134
|
-
- lib/bashly/views/command/
|
135
|
-
- lib/bashly/views/command/
|
136
|
-
- lib/bashly/views/command/
|
137
|
-
- lib/bashly/views/command/
|
138
|
-
- lib/bashly/views/command/
|
139
|
-
- lib/bashly/views/command/
|
140
|
-
- lib/bashly/views/command/
|
141
|
-
- lib/bashly/views/command/
|
142
|
-
- lib/bashly/views/command/
|
143
|
-
- lib/bashly/views/command/
|
144
|
-
- lib/bashly/views/command/
|
145
|
-
- lib/bashly/views/command/
|
146
|
-
- lib/bashly/views/command/
|
147
|
-
- lib/bashly/views/command/
|
148
|
-
- lib/bashly/views/command/
|
149
|
-
- lib/bashly/views/command/
|
150
|
-
- lib/bashly/views/command/
|
151
|
-
- lib/bashly/views/command/
|
152
|
-
- lib/bashly/views/command/
|
153
|
-
- lib/bashly/views/command/
|
154
|
-
- lib/bashly/views/command/
|
155
|
-
- lib/bashly/views/command/
|
156
|
-
- lib/bashly/views/command/
|
157
|
-
- lib/bashly/views/command/
|
158
|
-
- lib/bashly/views/command/
|
159
|
-
- lib/bashly/views/command/
|
160
|
-
- lib/bashly/views/command/
|
161
|
-
- lib/bashly/views/command/
|
162
|
-
- lib/bashly/views/command/
|
163
|
-
- lib/bashly/views/command/
|
164
|
-
- lib/bashly/views/command/
|
165
|
-
- lib/bashly/views/command/
|
166
|
-
- lib/bashly/views/command/
|
167
|
-
- lib/bashly/views/command/
|
168
|
-
- lib/bashly/views/command/
|
169
|
-
- lib/bashly/views/command/
|
170
|
-
- lib/bashly/views/
|
171
|
-
- lib/bashly/views/
|
172
|
-
- lib/bashly/views/
|
173
|
-
- lib/bashly/views/flag/
|
174
|
-
- lib/bashly/views/flag/
|
175
|
-
- lib/bashly/views/flag/
|
176
|
-
- lib/bashly/views/flag/
|
177
|
-
- lib/bashly/views/
|
178
|
-
- lib/bashly/views/
|
179
|
-
- lib/bashly/views/wrapper/
|
157
|
+
- lib/bashly/views/README.md
|
158
|
+
- lib/bashly/views/argument/usage.gtx
|
159
|
+
- lib/bashly/views/argument/validations.gtx
|
160
|
+
- lib/bashly/views/command/catch_all_filter.gtx
|
161
|
+
- lib/bashly/views/command/command_fallback.gtx
|
162
|
+
- lib/bashly/views/command/command_filter.gtx
|
163
|
+
- lib/bashly/views/command/command_functions.gtx
|
164
|
+
- lib/bashly/views/command/default_assignments.gtx
|
165
|
+
- lib/bashly/views/command/default_initialize_script.gtx
|
166
|
+
- lib/bashly/views/command/default_root_script.gtx
|
167
|
+
- lib/bashly/views/command/default_script.gtx
|
168
|
+
- lib/bashly/views/command/dependencies_filter.gtx
|
169
|
+
- lib/bashly/views/command/environment_variables_filter.gtx
|
170
|
+
- lib/bashly/views/command/fixed_flags_filter.gtx
|
171
|
+
- lib/bashly/views/command/footer.gtx
|
172
|
+
- lib/bashly/views/command/function.gtx
|
173
|
+
- lib/bashly/views/command/initialize.gtx
|
174
|
+
- lib/bashly/views/command/inspect_args.gtx
|
175
|
+
- lib/bashly/views/command/long_usage.gtx
|
176
|
+
- lib/bashly/views/command/master_script.gtx
|
177
|
+
- lib/bashly/views/command/normalize_input.gtx
|
178
|
+
- lib/bashly/views/command/parse_requirements.gtx
|
179
|
+
- lib/bashly/views/command/parse_requirements_case.gtx
|
180
|
+
- lib/bashly/views/command/parse_requirements_case_catch_all.gtx
|
181
|
+
- lib/bashly/views/command/parse_requirements_case_repeatable.gtx
|
182
|
+
- lib/bashly/views/command/parse_requirements_case_simple.gtx
|
183
|
+
- lib/bashly/views/command/parse_requirements_while.gtx
|
184
|
+
- lib/bashly/views/command/required_args_filter.gtx
|
185
|
+
- lib/bashly/views/command/required_flags_filter.gtx
|
186
|
+
- lib/bashly/views/command/root_command.gtx
|
187
|
+
- lib/bashly/views/command/run.gtx
|
188
|
+
- lib/bashly/views/command/usage.gtx
|
189
|
+
- lib/bashly/views/command/usage_args.gtx
|
190
|
+
- lib/bashly/views/command/usage_commands.gtx
|
191
|
+
- lib/bashly/views/command/usage_environment_variables.gtx
|
192
|
+
- lib/bashly/views/command/usage_examples.gtx
|
193
|
+
- lib/bashly/views/command/usage_fixed_flags.gtx
|
194
|
+
- lib/bashly/views/command/usage_flags.gtx
|
195
|
+
- lib/bashly/views/command/user_filter.gtx
|
196
|
+
- lib/bashly/views/command/user_lib.gtx
|
197
|
+
- lib/bashly/views/command/version_command.gtx
|
198
|
+
- lib/bashly/views/command/whitelist_filter.gtx
|
199
|
+
- lib/bashly/views/environment_variable/usage.gtx
|
200
|
+
- lib/bashly/views/flag/case.gtx
|
201
|
+
- lib/bashly/views/flag/case_arg.gtx
|
202
|
+
- lib/bashly/views/flag/case_no_arg.gtx
|
203
|
+
- lib/bashly/views/flag/conflicts.gtx
|
204
|
+
- lib/bashly/views/flag/usage.gtx
|
205
|
+
- lib/bashly/views/flag/validations.gtx
|
206
|
+
- lib/bashly/views/wrapper/bash3_bouncer.gtx
|
207
|
+
- lib/bashly/views/wrapper/header.gtx
|
208
|
+
- lib/bashly/views/wrapper/wrapper.gtx
|
180
209
|
homepage: https://github.com/dannyben/bashly
|
181
210
|
licenses:
|
182
211
|
- MIT
|
@@ -200,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
229
|
- !ruby/object:Gem::Version
|
201
230
|
version: '0'
|
202
231
|
requirements: []
|
203
|
-
rubygems_version: 3.3.
|
232
|
+
rubygems_version: 3.3.14
|
204
233
|
signing_key:
|
205
234
|
specification_version: 4
|
206
235
|
summary: Bash Command Line Tool Generator
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module Bashly
|
2
|
-
# This is a `Command` concern responsible for providing additional scopes.
|
3
|
-
module CommandScopes
|
4
|
-
# Returns an array of all full names (including aliases and aliases of
|
5
|
-
# parents)
|
6
|
-
def all_full_names
|
7
|
-
if parent_command
|
8
|
-
parent_command.all_full_names.product(aliases).map { |a| a.join ' ' }
|
9
|
-
else
|
10
|
-
aliases
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Returns a full list of the Command names and aliases combined
|
15
|
-
def command_aliases
|
16
|
-
commands.map(&:aliases).flatten
|
17
|
-
end
|
18
|
-
|
19
|
-
# Returns only the names of the Commands
|
20
|
-
def command_names
|
21
|
-
commands.map &:name
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns a flat array containing all the commands in this tree.
|
25
|
-
# This includes self + children + grandchildres + ...
|
26
|
-
def deep_commands
|
27
|
-
result = []
|
28
|
-
commands.each do |command|
|
29
|
-
result << command
|
30
|
-
if command.commands.any?
|
31
|
-
result += command.deep_commands
|
32
|
-
end
|
33
|
-
end
|
34
|
-
result
|
35
|
-
end
|
36
|
-
|
37
|
-
# If any of this command's subcommands has the default option set to
|
38
|
-
# true, this default command will be returned, nil otherwise.
|
39
|
-
def default_command
|
40
|
-
commands.find { |c| c.default }
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns an array of all the default Args
|
44
|
-
def default_args
|
45
|
-
args.select &:default
|
46
|
-
end
|
47
|
-
|
48
|
-
# Returns an array of all the default Environment Variables
|
49
|
-
def default_environment_variables
|
50
|
-
environment_variables.select &:default
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns an array of all the default Flags
|
54
|
-
def default_flags
|
55
|
-
flags.select &:default
|
56
|
-
end
|
57
|
-
|
58
|
-
# Returns an array of all the required Arguments
|
59
|
-
def required_args
|
60
|
-
args.select &:required
|
61
|
-
end
|
62
|
-
|
63
|
-
# Returns an array of all the required EnvironmentVariables
|
64
|
-
def required_environment_variables
|
65
|
-
environment_variables.select &:required
|
66
|
-
end
|
67
|
-
|
68
|
-
# Returns an array of all the required Flags
|
69
|
-
def required_flags
|
70
|
-
flags.select &:required
|
71
|
-
end
|
72
|
-
|
73
|
-
# Returns an array of all the args with a whitelist
|
74
|
-
def whitelisted_args
|
75
|
-
args.select &:allowed
|
76
|
-
end
|
77
|
-
|
78
|
-
# Returns an array of all the flags with a whitelist arg
|
79
|
-
def whitelisted_flags
|
80
|
-
flags.select &:allowed
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
echo " <%= label %>"
|
3
|
-
printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
|
4
|
-
% if allowed
|
5
|
-
printf " <%= strings[:allowed] % { values: allowed.join(', ') } -%>\n"
|
6
|
-
% end
|
7
|
-
% if default
|
8
|
-
printf " <%= strings[:default] % { value: default } -%>\n"
|
9
|
-
% end
|
10
|
-
echo
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if default_command
|
3
|
-
"" )
|
4
|
-
<%= function_name %>_usage
|
5
|
-
exit 1
|
6
|
-
;;
|
7
|
-
|
8
|
-
* )
|
9
|
-
action="<%= default_command.name %>"
|
10
|
-
<%= default_command.function_name %>_parse_requirements "$@"
|
11
|
-
shift $#
|
12
|
-
;;
|
13
|
-
% elsif extensible.is_a? String
|
14
|
-
"" )
|
15
|
-
<%= function_name %>_usage
|
16
|
-
exit 1
|
17
|
-
;;
|
18
|
-
|
19
|
-
* )
|
20
|
-
if [[ -x "$(command -v "<%= extensible %>")" ]]; then
|
21
|
-
exec <%= extensible %> "$@"
|
22
|
-
else
|
23
|
-
<%= function_name %>_usage
|
24
|
-
exit 1
|
25
|
-
fi
|
26
|
-
% elsif extensible
|
27
|
-
"" )
|
28
|
-
<%= function_name %>_usage
|
29
|
-
exit 1
|
30
|
-
;;
|
31
|
-
|
32
|
-
* )
|
33
|
-
if [[ -x "$(command -v "<%= function_name %>-$action")" ]]; then
|
34
|
-
shift
|
35
|
-
exec "<%= function_name %>-$action" "$@"
|
36
|
-
else
|
37
|
-
<%= function_name %>_usage
|
38
|
-
exit 1
|
39
|
-
fi
|
40
|
-
% else
|
41
|
-
* )
|
42
|
-
<%= function_name %>_usage
|
43
|
-
exit 1
|
44
|
-
;;
|
45
|
-
% end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if commands.any?
|
3
|
-
action=${1:-}
|
4
|
-
|
5
|
-
case $action in
|
6
|
-
-* )
|
7
|
-
;;
|
8
|
-
|
9
|
-
% commands.each do |command|
|
10
|
-
<%= command.aliases.join " | " %> )
|
11
|
-
action="<%= command.name %>"
|
12
|
-
shift
|
13
|
-
<%= command.function_name %>_parse_requirements "$@"
|
14
|
-
shift $#
|
15
|
-
;;
|
16
|
-
|
17
|
-
% end
|
18
|
-
<%= render :command_fallback %>
|
19
|
-
esac
|
20
|
-
% else
|
21
|
-
action="<%= action_name %>"
|
22
|
-
% end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% default_args.each do |arg|
|
3
|
-
[[ -n ${args[<%= arg.name %>]:-} ]] || args[<%= arg.name %>]="<%= arg.default %>"
|
4
|
-
% end
|
5
|
-
% default_flags.each do |flag|
|
6
|
-
[[ -n ${args[<%= flag.long %>]:-} ]] || args[<%= flag.long %>]="<%= flag.default %>"
|
7
|
-
% end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if default_environment_variables.any?
|
3
|
-
% default_environment_variables.each do |env_var|
|
4
|
-
export <%= env_var.name.upcase %>="${<%= env_var.name.upcase %>:-<%= env_var.default %>}"
|
5
|
-
% end
|
6
|
-
% end
|
7
|
-
% if required_environment_variables.any?
|
8
|
-
% required_environment_variables.each do |env_var|
|
9
|
-
if [[ -z "${<%= env_var.name.upcase %>:-}" ]]; then
|
10
|
-
printf "<%= strings[:missing_required_environment_variable] % { var: env_var.name.upcase } %>\n"
|
11
|
-
exit 1
|
12
|
-
fi
|
13
|
-
% end
|
14
|
-
% end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
case "${1:-}" in
|
3
|
-
% if root_command?
|
4
|
-
% if short_flag_exist? "-v"
|
5
|
-
--version )
|
6
|
-
% else
|
7
|
-
--version | -v )
|
8
|
-
% end
|
9
|
-
version_command
|
10
|
-
exit
|
11
|
-
;;
|
12
|
-
|
13
|
-
% end
|
14
|
-
% if short_flag_exist? "-h"
|
15
|
-
--help )
|
16
|
-
% else
|
17
|
-
--help | -h )
|
18
|
-
% end
|
19
|
-
long_usage=yes
|
20
|
-
<%= function_name %>_usage
|
21
|
-
exit
|
22
|
-
;;
|
23
|
-
|
24
|
-
esac
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
inspect_args() {
|
3
|
-
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
4
|
-
if (( ${#args[@]} )); then
|
5
|
-
echo args:
|
6
|
-
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
|
7
|
-
else
|
8
|
-
echo args: none
|
9
|
-
fi
|
10
|
-
|
11
|
-
if (( ${#other_args[@]} )); then
|
12
|
-
echo
|
13
|
-
echo other_args:
|
14
|
-
echo "- \${other_args[*]} = ${other_args[*]}"
|
15
|
-
for i in "${!other_args[@]}"; do
|
16
|
-
echo "- \${other_args[$i]} = ${other_args[$i]}"
|
17
|
-
done
|
18
|
-
fi
|
19
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
<%= render :root_command if commands.empty? %>
|
3
|
-
<%= render :version_command %>
|
4
|
-
<%= render :usage %>
|
5
|
-
<%= render :normalize_input %>
|
6
|
-
<%= render :inspect_args %>
|
7
|
-
<%= render :user_lib if user_lib.any? %>
|
8
|
-
<%= render :command_functions %>
|
9
|
-
<%= render :parse_requirements %>
|
10
|
-
<%= render :initialize %>
|
11
|
-
<%= render :run %>
|
12
|
-
|
13
|
-
initialize
|
14
|
-
run "$@"
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
normalize_input() {
|
3
|
-
local arg flags
|
4
|
-
|
5
|
-
while [[ $# -gt 0 ]]; do
|
6
|
-
arg="$1"
|
7
|
-
if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
|
8
|
-
input+=("${BASH_REMATCH[1]}")
|
9
|
-
input+=("${BASH_REMATCH[2]}")
|
10
|
-
elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
|
11
|
-
input+=("${BASH_REMATCH[1]}")
|
12
|
-
input+=("${BASH_REMATCH[2]}")
|
13
|
-
elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
|
14
|
-
flags="${BASH_REMATCH[1]}"
|
15
|
-
for (( i=0 ; i < ${#flags} ; i++ )); do
|
16
|
-
input+=("-${flags:i:1}")
|
17
|
-
done
|
18
|
-
else
|
19
|
-
input+=("$arg")
|
20
|
-
fi
|
21
|
-
|
22
|
-
shift
|
23
|
-
done
|
24
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if root_command?
|
3
|
-
parse_requirements() {
|
4
|
-
% else
|
5
|
-
<%= function_name %>_parse_requirements() {
|
6
|
-
% end
|
7
|
-
<%= render(:fixed_flags_filter).indent 2 %>
|
8
|
-
<%= render(:environment_variables_filter).indent 2 %>
|
9
|
-
<%= render(:dependencies_filter).indent 2 %>
|
10
|
-
<%= render(:command_filter).indent 2 %>
|
11
|
-
<%= render(:parse_requirements_while).indent 2 %>
|
12
|
-
<%= render(:required_args_filter).indent 2 %>
|
13
|
-
<%= render(:required_flags_filter).indent 2 %>
|
14
|
-
<%= render(:catch_all_filter).indent 2 %>
|
15
|
-
<%= render(:default_assignments).indent 2 %>
|
16
|
-
<%= render(:whitelist_filter).indent 2 %>
|
17
|
-
<%= render(:user_filter).indent 2 %>
|
18
|
-
}
|
19
|
-
|
20
|
-
% commands.each do |command|
|
21
|
-
<%= command.render :parse_requirements %>
|
22
|
-
% end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if args.any?
|
3
|
-
% condition = "if"
|
4
|
-
% args.each do |arg|
|
5
|
-
<%= condition %> [[ -z ${args[<%= arg.name %>]+x} ]]; then
|
6
|
-
<%= arg.render(:validations).indent 2 %>
|
7
|
-
args[<%= arg.name %>]=$1
|
8
|
-
shift
|
9
|
-
% condition = "elif"
|
10
|
-
% end
|
11
|
-
else
|
12
|
-
other_args+=("$1")
|
13
|
-
shift
|
14
|
-
fi
|
15
|
-
% else
|
16
|
-
other_args+=("$1")
|
17
|
-
shift
|
18
|
-
% end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% condition = "if"
|
3
|
-
% args.each do |arg|
|
4
|
-
<%= condition %> [[ -z ${args[<%= arg.name %>]+x} ]]; then
|
5
|
-
<%= arg.render(:validations).indent 2 %>
|
6
|
-
% if arg.repeatable
|
7
|
-
args[<%= arg.name %>]="\"$1\""
|
8
|
-
shift
|
9
|
-
else
|
10
|
-
args[<%= arg.name %>]="${args[<%= arg.name %>]} \"$1\""
|
11
|
-
shift
|
12
|
-
% else
|
13
|
-
args[<%= arg.name %>]=$1
|
14
|
-
shift
|
15
|
-
% end
|
16
|
-
% condition = "elif"
|
17
|
-
% end
|
18
|
-
fi
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<%= view_marker %>
|
2
|
-
% if args.any?
|
3
|
-
% condition = "if"
|
4
|
-
% args.each do |arg|
|
5
|
-
<%= condition %> [[ -z ${args[<%= arg.name %>]+x} ]]; then
|
6
|
-
<%= arg.render(:validations).indent 2 %>
|
7
|
-
args[<%= arg.name %>]=$1
|
8
|
-
shift
|
9
|
-
% condition = "elif"
|
10
|
-
% end
|
11
|
-
else
|
12
|
-
printf "<%= strings[:invalid_argument] %>\n" "$key"
|
13
|
-
exit 1
|
14
|
-
fi
|
15
|
-
% else
|
16
|
-
printf "<%= strings[:invalid_argument] %>\n" "$key"
|
17
|
-
exit 1
|
18
|
-
% end
|