bashly 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/bashly/models/command.rb +10 -0
- data/lib/bashly/templates/lib/sample_function.sh +1 -1
- data/lib/bashly/templates/strings.yml +1 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/argument/usage.erb +3 -0
- data/lib/bashly/views/command/default_assignments.erb +7 -0
- data/lib/bashly/views/command/parse_requirements.erb +1 -0
- data/lib/bashly/views/flag/usage.erb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36db0864b7a077abc473fbad4aa91d14b7428e914be51b537f583f1dc2f97490
|
4
|
+
data.tar.gz: 1e6c19c9cb0b05e09287b3c4e0986fa1c6d1d001f5d03e4c9fd70a72dfe768dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d63a0ebf4158eaeb220a13b6f2ac4ea4c092f930281450cb7cf8d9e85fe495c46e5fa504fb77df19fba3a8e47c71027c6a713f349d108b24f6c930090bdbf8a
|
7
|
+
data.tar.gz: fca3133104b49a68468aacf5a01ef28ca8374df6e1b177bf380fbb6dd6bcc618bf69c1f7022745b34789965abc0534fab2960a7cb57906ce6ba636ae2705cc50
|
data/README.md
CHANGED
@@ -26,6 +26,13 @@ $ gem install bashly
|
|
26
26
|
```
|
27
27
|
|
28
28
|
|
29
|
+
Prerequisites
|
30
|
+
--------------------------------------------------
|
31
|
+
|
32
|
+
The bash scripts generated by bashly require bash 4 or higher due to heavy
|
33
|
+
use of associative arrays.
|
34
|
+
|
35
|
+
|
29
36
|
What is Bashly
|
30
37
|
--------------------------------------------------
|
31
38
|
|
@@ -159,6 +166,7 @@ bash function.
|
|
159
166
|
`name` | The name of the argument.
|
160
167
|
`help` | The message to display when using `--help`. Can have multiple lines.
|
161
168
|
`required` | Specify if this argument is required. Note that once you define an optional argument (without required: true) then you cannot define required arguments after it.
|
169
|
+
`default` | The value to use in case it is not provided by the user. Implies that this argument is optional.
|
162
170
|
|
163
171
|
### Flag options
|
164
172
|
|
@@ -173,6 +181,7 @@ short form).
|
|
173
181
|
`help` | The text to display when using `--help`. Can have multiple lines.
|
174
182
|
`arg` | If the flag requires an argument, specify its name here.
|
175
183
|
`required` | Specify if this flag is required.
|
184
|
+
`default` | The value to use in case it is not provided by the user. Implies that this flag is optional, and only makes sense when the flag has an argument.
|
176
185
|
|
177
186
|
#### Special handling for -v and -h
|
178
187
|
|
@@ -55,12 +55,22 @@ module Bashly
|
|
55
55
|
result
|
56
56
|
end
|
57
57
|
|
58
|
+
# Returns an array of all the default Args
|
59
|
+
def default_args
|
60
|
+
args.select &:default
|
61
|
+
end
|
62
|
+
|
58
63
|
# If any of this command's subcommands has the default option set to
|
59
64
|
# true, this default command will be returned, nil otherwise.
|
60
65
|
def default_command
|
61
66
|
commands.find { |c| c.default }
|
62
67
|
end
|
63
68
|
|
69
|
+
# Returns an array of all the default Flags
|
70
|
+
def default_flags
|
71
|
+
flags.select &:default
|
72
|
+
end
|
73
|
+
|
64
74
|
# Returns an array of EnvironmentVariables
|
65
75
|
def environment_variables
|
66
76
|
return [] unless options["environment_variables"]
|
data/lib/bashly/version.rb
CHANGED
@@ -0,0 +1,7 @@
|
|
1
|
+
# :command.default_assignments
|
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 -%>
|
@@ -11,6 +11,7 @@ parse_requirements() {
|
|
11
11
|
<%= render(:required_args_filter).indent 2 %>
|
12
12
|
<%= render(:required_flags_filter).indent 2 %>
|
13
13
|
<%= render(:parse_requirements_while).indent 2 %>
|
14
|
+
<%= render(:default_assignments).indent 2 %>
|
14
15
|
}
|
15
16
|
|
16
17
|
<%- commands.each do |command| %>
|
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.7
|
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: 2020-02-
|
11
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/bashly/views/argument/usage.erb
|
94
94
|
- lib/bashly/views/command/command_filter.erb
|
95
95
|
- lib/bashly/views/command/command_functions.erb
|
96
|
+
- lib/bashly/views/command/default_assignments.erb
|
96
97
|
- lib/bashly/views/command/default_initialize_script.erb
|
97
98
|
- lib/bashly/views/command/default_root_script.erb
|
98
99
|
- lib/bashly/views/command/default_script.erb
|