bashly 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/bashly/models/base.rb +1 -0
- data/lib/bashly/models/command.rb +24 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/inspect_args.erb +9 -0
- data/lib/bashly/views/command/parse_requirements_case.erb +8 -0
- data/lib/bashly/views/command/parse_requirements_while.erb +6 -0
- data/lib/bashly/views/command/run.erb +1 -0
- data/lib/bashly/views/command/usage_args.erb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c9356631608d3410b0feb58688189fe86eaa382cc69331e290dbf5f66dfdb0
|
4
|
+
data.tar.gz: 49a1f418c8b8f2743eeee74337e1a86239563a55e58f3afdabb2ecd8f8a9960c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45f8ed4008439aee2571e768160cf5109dcf7a2ca770bccd74367ee1983e535a6db9c5cd28ec6438ca5de2091f4e0c7c4a86a3cd78e20ff19a283e840bff4760
|
7
|
+
data.tar.gz: 1a31d5dbe060275a17874d3bcce680d89a3c5a4f58582b011d0b955370d8c43092064b2da3b2033b705a3e1edd0d8b4501e9fc6c2ffe1f1e2ba2400e2b952a9f
|
data/README.md
CHANGED
@@ -196,19 +196,19 @@ The `bashly.yml` configuration file consists of these types:
|
|
196
196
|
Unless otherwise specified, these definitiona can be used for both the root
|
197
197
|
command and subcommands (under the `commands` definition).
|
198
198
|
|
199
|
-
|
200
199
|
Option | Description
|
201
200
|
-----------|-------------
|
202
201
|
`name` | The name of the script or subcommand.
|
203
202
|
`short` | An additional, optional pattern - usually used to denote a one letter variation of the command name. You can add `*` as a suffix, to denote a "starts with" pattern - for example `short: m*`. *Applicable only in subcommands*.
|
204
203
|
`help` | The header text to display when using `--help`. This option can have multiple lines. In this case, the first line will be used as summary wherever appropriate.
|
205
204
|
`version` | The string to display when using `--version`. *Applicable only in the main command*.
|
206
|
-
`default` | Setting this to `
|
205
|
+
`default` | Setting this to `true` on any command, will make unrecognized command line arguments to be passed to this command. *Applicable only in subcommands*.
|
207
206
|
`examples` | Specify an array of examples to show when using `--help`. Each example can have multiple lines.
|
208
207
|
`environment_variables` | Specify an array of environment variables needed by your script.
|
209
208
|
`commands` | Specify the array of commands. Each command will have its own args and flags. Note: if `commands` is provided, you cannot specify flags or args at the same level.
|
210
209
|
`args` | Specify the array of positional arguments this script needs.
|
211
210
|
`flags` | Specify the array of option flags this script needs.
|
211
|
+
`catch_all` | Specify that this command should allow for additional arbitrary arguments or flags. It can be set in one of three ways:<br>- Set to `true` to just enable it.<br>- Set to a string, to use this string in the usage help text.<br>- Set to a hash containing `label` and `help` keys, to show a detailed help for it when running with `--help`.
|
212
212
|
`dependencies` | Specify an array of any required external dependencies (commands). The script execution will be halted with a friendly error unless all dependency commands exist.
|
213
213
|
`group` | In case you have many commands, use this option to specify a caption to display before this command. This option is purely for display purposes, and needs to be specified only for the first command in each group.
|
214
214
|
|
data/lib/bashly/models/base.rb
CHANGED
@@ -28,6 +28,29 @@ module Bashly
|
|
28
28
|
help ? "#{full_name} - #{summary}" : full_name
|
29
29
|
end
|
30
30
|
|
31
|
+
# Returns a label for the catch_all directive
|
32
|
+
def catch_all_label
|
33
|
+
return nil unless catch_all
|
34
|
+
|
35
|
+
if catch_all.is_a? String
|
36
|
+
"#{catch_all.upcase}..."
|
37
|
+
elsif catch_all.is_a?(Hash) and catch_all['label'].is_a?(String)
|
38
|
+
"#{catch_all['label'].upcase}..."
|
39
|
+
else
|
40
|
+
"..."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def catch_all_help
|
45
|
+
return nil unless catch_all
|
46
|
+
|
47
|
+
if catch_all.is_a?(Hash) and catch_all['help'].is_a?(String)
|
48
|
+
catch_all['help']
|
49
|
+
else
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
31
54
|
# Returns only the names of the Commands
|
32
55
|
def command_names
|
33
56
|
commands.map &:name
|
@@ -159,6 +182,7 @@ module Bashly
|
|
159
182
|
result << arg.usage_string
|
160
183
|
end
|
161
184
|
result << "[options]" unless flags.empty?
|
185
|
+
result << "[#{catch_all_label}]" if catch_all
|
162
186
|
result.join " "
|
163
187
|
end
|
164
188
|
|
data/lib/bashly/version.rb
CHANGED
@@ -7,4 +7,13 @@ inspect_args() {
|
|
7
7
|
else
|
8
8
|
echo args: none
|
9
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
|
10
19
|
}
|
@@ -8,9 +8,17 @@
|
|
8
8
|
<%- condition = "elif" -%>
|
9
9
|
<%- end -%>
|
10
10
|
else
|
11
|
+
<%- if catch_all -%>
|
12
|
+
other_args+=("$1")
|
13
|
+
shift
|
14
|
+
<%- else -%>
|
11
15
|
printf "<%= strings[:invalid_argument] %>\n" "$key"
|
12
16
|
exit 1
|
17
|
+
<%- end -%>
|
13
18
|
fi
|
19
|
+
<%- elsif catch_all -%>
|
20
|
+
other_args+=("$1")
|
21
|
+
shift
|
14
22
|
<%- else -%>
|
15
23
|
printf "<%= strings[:invalid_argument] %>\n" "$key"
|
16
24
|
exit 1
|
@@ -8,9 +8,15 @@ while [[ $# -gt 0 ]]; do
|
|
8
8
|
<%- end -%>
|
9
9
|
|
10
10
|
-* )
|
11
|
+
<%- if catch_all -%>
|
12
|
+
other_args+=("$1")
|
13
|
+
shift
|
14
|
+
;;
|
15
|
+
<%- else -%>
|
11
16
|
printf "<%= strings[:invalid_flag] %>\n" "$key"
|
12
17
|
exit 1
|
13
18
|
;;
|
19
|
+
<%- end -%>
|
14
20
|
|
15
21
|
* )
|
16
22
|
<%= render(:parse_requirements_case).indent 4 %>
|
@@ -4,3 +4,9 @@ printf "<%= strings[:arguments] %>\n"
|
|
4
4
|
<%- args.each do |arg| -%>
|
5
5
|
<%= arg.render(:usage) %>
|
6
6
|
<%- end -%>
|
7
|
+
|
8
|
+
<%- if catch_all_help -%>
|
9
|
+
echo " <%= catch_all_label %>"
|
10
|
+
printf "<%= catch_all_help.wrap(76).indent(4).sanitize_for_print %>\n"
|
11
|
+
echo
|
12
|
+
<%- 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: 0.4.
|
4
|
+
version: 0.4.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: 2021-
|
11
|
+
date: 2021-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
|
-
rubygems_version: 3.2.
|
149
|
+
rubygems_version: 3.2.16
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Bash Command Line Tool Generator
|