bashly 0.3.4 → 0.3.5
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 -1
- data/lib/bashly/models/command.rb +5 -0
- data/lib/bashly/templates/strings.yml +0 -2
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/fixed_flags_filter.erb +9 -1
- data/lib/bashly/views/command/usage.erb +3 -3
- data/lib/bashly/views/command/usage_fixed_flags.erb +8 -0
- data/lib/bashly/views/flag/case.erb +1 -1
- 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: 95bc5fa6ee6c14e2e4cd269aecbfef7af9f005e7837c182c2f222d4640778e40
|
4
|
+
data.tar.gz: c8214a96d5d63094cb6f86e07022022f30b471da362b4aa087fe16ddaf96aada
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25fd6d234783d9eb96a5e4f4a5bcc836740cbb6ee5ff2f5486a4fcea376a5e61c31f6b5eb762693708225ee8b2a2aac3d163d23d37d07dfe902687ee8d4a22b
|
7
|
+
data.tar.gz: 8bc3e1595cdb52c6001d55600f7fb4a1fda2d7d525b933641e04f4041de694354895eeb37d0e53d6c0cdc286b632643dfb812c8fb40cf958e93f94a5a005dcf5
|
data/README.md
CHANGED
@@ -163,7 +163,7 @@ bash function.
|
|
163
163
|
### Flag options
|
164
164
|
|
165
165
|
The flag's value will be available to you as `${args[--output]}` in your
|
166
|
-
bash function (regardless of whether the user provided
|
166
|
+
bash function (regardless of whether the user provided it with the long or
|
167
167
|
short form).
|
168
168
|
|
169
169
|
Option | Description
|
@@ -174,6 +174,12 @@ short form).
|
|
174
174
|
`arg` | If the flag requires an argument, specify its name here.
|
175
175
|
`required` | Specify if this flag is required.
|
176
176
|
|
177
|
+
#### Special handling for -v and -h
|
178
|
+
|
179
|
+
The `-v` and `-h` flags will be used as the short options for `--version` and
|
180
|
+
`--help` respectively **only if you are not using them in any of your own
|
181
|
+
flags**.
|
182
|
+
|
177
183
|
### Environment Variable options
|
178
184
|
|
179
185
|
The below configuration generates this environment variable usage text:
|
@@ -136,6 +136,11 @@ module Bashly
|
|
136
136
|
parents.empty?
|
137
137
|
end
|
138
138
|
|
139
|
+
# Returns true if one of the flags matches the provided short code
|
140
|
+
def short_flag_exist?(flag)
|
141
|
+
flags.select { |f| f.short == flag }.any?
|
142
|
+
end
|
143
|
+
|
139
144
|
# Returns a constructed string suitable for Usage pattern
|
140
145
|
def usage_string
|
141
146
|
result = [full_name]
|
@@ -14,8 +14,6 @@ group: "%{group} Commands:"
|
|
14
14
|
command_shortcut: "Shortcut: %{short}"
|
15
15
|
default_command_summary: "%{summary} (default)"
|
16
16
|
required: "(required)"
|
17
|
-
help_flag: "--help | -h"
|
18
|
-
version_flag: "--version"
|
19
17
|
|
20
18
|
# Fixed flags help text
|
21
19
|
help_flag_text: Show this help
|
data/lib/bashly/version.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
# :command.fixed_flag_filter
|
2
2
|
case "$1" in
|
3
|
+
<%- if short_flag_exist? "-v" -%>
|
3
4
|
--version )
|
5
|
+
<%- else -%>
|
6
|
+
--version | -v )
|
7
|
+
<%- end -%>
|
4
8
|
version_command
|
5
9
|
exit 1
|
6
10
|
;;
|
7
11
|
|
8
|
-
|
12
|
+
<%- if short_flag_exist? "-h" -%>
|
13
|
+
--help )
|
14
|
+
<%- else -%>
|
15
|
+
--help | -h )
|
16
|
+
<%- end -%>
|
9
17
|
long_usage=yes
|
10
18
|
<%= function_name %>_usage
|
11
19
|
exit 1
|
@@ -23,12 +23,12 @@
|
|
23
23
|
printf "<%= strings[:usage] %>\n"
|
24
24
|
printf " <%= usage_string %>\n"
|
25
25
|
<%- if commands.any? -%>
|
26
|
-
printf " <%= full_name %> [command] --help | -h
|
26
|
+
printf " <%= full_name %> [command] --help<%= " | -h" unless short_flag_exist? "-h" -%>\n"
|
27
27
|
<%- else -%>
|
28
|
-
printf " <%= full_name %> <%=
|
28
|
+
printf " <%= full_name %> --help<%= " | -h" unless short_flag_exist? "-h" -%>\n"
|
29
29
|
<%- end -%>
|
30
30
|
<%- if root_command? -%>
|
31
|
-
printf " <%= full_name %> <%=
|
31
|
+
printf " <%= full_name %> --version<%= " | -v" unless short_flag_exist? "-v" -%>\n"
|
32
32
|
<%- end -%>
|
33
33
|
echo
|
34
34
|
<%= render(:usage_commands).indent 2 if commands.any? %>
|
@@ -1,9 +1,17 @@
|
|
1
1
|
# :command.usage_fixed_flags
|
2
|
+
<%- if short_flag_exist? "-h" -%>
|
3
|
+
echo " --help"
|
4
|
+
<%- else -%>
|
2
5
|
echo " --help, -h"
|
6
|
+
<%- end -%>
|
3
7
|
printf " <%= strings[:help_flag_text] %>\n"
|
4
8
|
echo
|
5
9
|
<%- if root_command? -%>
|
10
|
+
<%- if short_flag_exist? "-v" -%>
|
6
11
|
echo " --version"
|
12
|
+
<%- else -%>
|
13
|
+
echo " --version, -v"
|
14
|
+
<%- end -%>
|
7
15
|
printf " <%= strings[:version_flag_text] %>\n"
|
8
16
|
echo
|
9
17
|
<%- 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.3.
|
4
|
+
version: 0.3.5
|
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: 2019-12-
|
11
|
+
date: 2019-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|