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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffda5465535e873bf8f7beea1491d33ffd9e417adcd7cd2a79d8798e24fad6e2
4
- data.tar.gz: 4b4f2a5fe32494fd4527b88be16d5f3b414ce46f07eb421397f5f3715da2351e
3
+ metadata.gz: 36db0864b7a077abc473fbad4aa91d14b7428e914be51b537f583f1dc2f97490
4
+ data.tar.gz: 1e6c19c9cb0b05e09287b3c4e0986fa1c6d1d001f5d03e4c9fd70a72dfe768dc
5
5
  SHA512:
6
- metadata.gz: 1fba52e408663920eb145112f9c80bc0a6ce4731f017688ca299c8fad975c4bd4ef2fc8e330cf6e5452f797502a44a43342a95ccf9e95b50935c378a56ade85a
7
- data.tar.gz: 4670e9c1b054c36cbb91d1c2264d37f4011ab8e242b0b47b5e07c85558d463fa806a299fa88f5c6b0aa2b61fc44b4fae7641727549f910aa3c9047b087ebaec1
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"]
@@ -6,7 +6,7 @@
6
6
  # recommended to have a separate file for each function.
7
7
  #
8
8
  # Subdirectories will also be scanned for *.sh, so you have no reason not
9
- # to organize your code nearly.
9
+ # to organize your code neatly.
10
10
  #
11
11
  sample_function() {
12
12
  echo "it works"
@@ -14,6 +14,7 @@ group: "%{group} Commands:"
14
14
  command_shortcut: "Shortcut: %{short}"
15
15
  default_command_summary: "%{summary} (default)"
16
16
  required: "(required)"
17
+ default: "Default: %{value}"
17
18
 
18
19
  # Fixed flags help text
19
20
  help_flag_text: Show this help
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
@@ -1,4 +1,7 @@
1
1
  # :argument.usage
2
2
  echo " <%= name.upcase %>"
3
3
  printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
4
+ <%- if default -%>
5
+ printf " <%= strings[:default] % { value: default } -%>\n"
6
+ <%- end -%>
4
7
  echo
@@ -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| %>
@@ -1,4 +1,7 @@
1
1
  # :flag.usage
2
2
  echo " <%= usage_string extended: true %>"
3
3
  printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
4
+ <%- if default -%>
5
+ printf " <%= strings[:default] % { value: default } -%>\n"
6
+ <%- end -%>
4
7
  echo
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.6
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-06 00:00:00.000000000 Z
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