bashly 0.6.4 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bashly/commands/generate.rb +11 -6
  3. data/lib/bashly/extensions/string.rb +1 -1
  4. data/lib/bashly/models/command.rb +2 -2
  5. data/lib/bashly/models/script.rb +19 -1
  6. data/lib/bashly/templates/lib/config.sh +17 -14
  7. data/lib/bashly/version.rb +1 -1
  8. data/lib/bashly/views/argument/usage.erb +4 -4
  9. data/lib/bashly/views/command/catch_all_filter.erb +2 -2
  10. data/lib/bashly/views/command/command_fallback.erb +5 -5
  11. data/lib/bashly/views/command/command_filter.erb +5 -5
  12. data/lib/bashly/views/command/command_functions.erb +2 -2
  13. data/lib/bashly/views/command/default_assignments.erb +4 -4
  14. data/lib/bashly/views/command/dependencies_filter.erb +4 -4
  15. data/lib/bashly/views/command/environment_variables_filter.erb +9 -9
  16. data/lib/bashly/views/command/fixed_flags_filter.erb +6 -6
  17. data/lib/bashly/views/command/initialize.erb +0 -5
  18. data/lib/bashly/views/command/master_script.erb +1 -0
  19. data/lib/bashly/views/command/normalize_input.erb +24 -0
  20. data/lib/bashly/views/command/parse_requirements.erb +5 -5
  21. data/lib/bashly/views/command/parse_requirements_case.erb +11 -11
  22. data/lib/bashly/views/command/parse_requirements_while.erb +5 -5
  23. data/lib/bashly/views/command/required_args_filter.erb +2 -2
  24. data/lib/bashly/views/command/required_flags_filter.erb +4 -4
  25. data/lib/bashly/views/command/run.erb +3 -1
  26. data/lib/bashly/views/command/usage_args.erb +6 -6
  27. data/lib/bashly/views/command/usage_commands.erb +12 -12
  28. data/lib/bashly/views/command/usage_environment_variables.erb +2 -2
  29. data/lib/bashly/views/command/usage_examples.erb +2 -2
  30. data/lib/bashly/views/command/usage_fixed_flags.erb +8 -8
  31. data/lib/bashly/views/command/usage_flags.erb +2 -2
  32. data/lib/bashly/views/command/user_lib.erb +2 -2
  33. data/lib/bashly/views/command/whitelist_filter.erb +4 -4
  34. data/lib/bashly/views/environment_variable/usage.erb +2 -2
  35. data/lib/bashly/views/flag/case.erb +3 -3
  36. data/lib/bashly/views/flag/usage.erb +4 -4
  37. data/lib/bashly/views/script/bash3_bouncer.erb +5 -0
  38. data/lib/bashly/views/script/header.erb +1 -0
  39. metadata +11 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 650f456561f180e0a39b2e6e0c66f6c5913438ac6301d44bff064470d602daba
4
- data.tar.gz: 2f64d00edb50ce738d506568600d8b73b898aad6563990460a80a52d912a6e66
3
+ metadata.gz: 6f0b22d0ac9bf41f91fed37e60996fa5175346a9e2e5e56158b760ededfef2a0
4
+ data.tar.gz: 39ffcd5e199b6b79fd04a4bd38e93d4703ad7aebce0ec4970b8250280112c5db
5
5
  SHA512:
6
- metadata.gz: 70427709c22c05bcfdfadb1daafaea8c87c5854b03488913c916ffb29861521c853eb5392f22c0c79b7bdc8fe359fc55389c0d6f0540493c250dd6ba1f7d79b5
7
- data.tar.gz: 2b2aa5dc0525edc81ce3c023583b0d829907de9e1656a00fdb37d6cd87e0b4ab788e70e71fe51763a661006f8ce8fdf950a7c3e7ffcce095edec5cc799e942ed
6
+ metadata.gz: fd57501ae8a6fc8b3072320dc7358b2097ef9b280b5e8b80efa52155c91a9fe56abbb73821ffc2b8a8a8e55caf7a61dd46ef29d8c88f49b2232cddfccff77a32
7
+ data.tar.gz: 83f7293f9b543d6330daedf6421678b3c321166751708dba0985d7aa18a9191510a3832bd2ac8d2a3510b09f9eb2064403798b38894c7227a63f8c86f52f04dc
@@ -3,11 +3,12 @@ module Bashly
3
3
  class Generate < Base
4
4
  help "Generate the bash script and required files"
5
5
 
6
- usage "bashly generate [--force --wrap FUNCTION]"
6
+ usage "bashly generate [--force --quiet --wrap FUNCTION]"
7
7
  usage "bashly generate (-h|--help)"
8
8
 
9
9
  option "-f --force", "Overwrite existing files"
10
10
  option "-w --wrap FUNCTION", "Wrap the entire script in a function so it can also be sourced"
11
+ option "-q --quiet", "Disable on-screen progress report"
11
12
 
12
13
  environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
13
14
  environment "BASHLY_TARGET_DIR", "The path to use for creating the bash script [default: .]"
@@ -18,13 +19,17 @@ module Bashly
18
19
  def run
19
20
  create_user_files
20
21
  create_master_script
21
- say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script"
22
+ quiet_say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script"
22
23
  end
23
24
 
24
25
  private
25
26
 
27
+ def quiet_say(message)
28
+ say message unless args['--quiet']
29
+ end
30
+
26
31
  def create_user_files
27
- say "creating user files in !txtgrn!#{Settings.source_dir}"
32
+ quiet_say "creating user files in !txtgrn!#{Settings.source_dir}"
28
33
 
29
34
  create_file "#{Settings.source_dir}/initialize.sh", command.render(:default_initialize_script)
30
35
 
@@ -50,17 +55,17 @@ module Bashly
50
55
 
51
56
  def create_file(file, content)
52
57
  if File.exist? file and !args['--force']
53
- say "skipped !txtgrn!#{file}!txtrst! (exists)"
58
+ quiet_say "skipped !txtgrn!#{file}!txtrst! (exists)"
54
59
  else
55
60
  File.write file, content
56
- say "created !txtgrn!#{file}"
61
+ quiet_say "created !txtgrn!#{file}"
57
62
  end
58
63
  end
59
64
 
60
65
  def create_master_script
61
66
  File.write master_script_path, script.code
62
67
  FileUtils.chmod "+x", master_script_path
63
- say "created !txtgrn!#{master_script_path}"
68
+ quiet_say "created !txtgrn!#{master_script_path}"
64
69
  end
65
70
 
66
71
  def script
@@ -24,7 +24,7 @@ class String
24
24
  end
25
25
 
26
26
  def lint
27
- gsub(/\n{2,}/, "\n\n")
27
+ gsub(/\s+\n/m, "\n\n")
28
28
  end
29
29
 
30
30
  end
@@ -209,7 +209,7 @@ module Bashly
209
209
  # This is meant to provide the user with the ability to add custom
210
210
  # functions
211
211
  def user_lib
212
- @user_lib ||= Dir["#{Settings.source_dir}/lib/**/*.sh"]
212
+ @user_lib ||= Dir["#{Settings.source_dir}/lib/**/*.sh"].sort
213
213
  end
214
214
 
215
215
  # Raise an exception if there are some serious issues with the command
@@ -238,4 +238,4 @@ module Bashly
238
238
 
239
239
  end
240
240
  end
241
- end
241
+ end
@@ -22,12 +22,30 @@ module Bashly
22
22
  private
23
23
 
24
24
  def header
25
- @header ||= render('header')
25
+ @header ||= header!
26
+ end
27
+
28
+ def header!
29
+ if File.exist? custom_header_path
30
+ File.read custom_header_path
31
+ else
32
+ default_header
33
+ end
34
+ end
35
+
36
+ def default_header
37
+ result = render('header')
38
+ result += render('bash3_bouncer') unless function_name
39
+ result
26
40
  end
27
41
 
28
42
  def body
29
43
  @body ||= command.render('master_script')
30
44
  end
45
+
46
+ def custom_header_path
47
+ @custom_header_path ||= "#{Settings.source_dir}/header.sh"
48
+ end
31
49
  end
32
50
  end
33
51
  end
@@ -10,7 +10,7 @@
10
10
  # ---
11
11
 
12
12
  # Create a new config file.
13
- # There is normally no need to use this fucntion, it is used by other
13
+ # There is normally no need to use this function, it is used by other
14
14
  # functions as needed.
15
15
  config_init() {
16
16
  CONFIG_FILE=${CONFIG_FILE:=config.ini}
@@ -20,8 +20,9 @@ config_init() {
20
20
  # Get a value from the config.
21
21
  # Usage: result=$(config_get hello)
22
22
  config_get() {
23
- key=$1
24
- regex="^$key *= *(.+)$"
23
+ local key=$1
24
+ local regex="^$key *= *(.+)$"
25
+ local value=""
25
26
 
26
27
  config_init
27
28
 
@@ -38,15 +39,16 @@ config_get() {
38
39
  # Add or update a key=value pair in the config.
39
40
  # Usage: config_set key value
40
41
  config_set() {
41
- key=$1
42
+ local key=$1
42
43
  shift
43
- value="$*"
44
+ local value="$*"
44
45
 
45
46
  config_init
46
47
 
47
- regex="^($key) *= *.+$"
48
- output=""
49
- found_key=""
48
+ local regex="^($key) *= *.+$"
49
+ local output=""
50
+ local found_key=""
51
+ local newline
50
52
 
51
53
  while IFS= read -r line || [ -n "$line" ]; do
52
54
  newline=$line
@@ -69,15 +71,14 @@ config_set() {
69
71
  # Delete a key from the config.
70
72
  # Usage: config_del key
71
73
  config_del() {
72
- key=$1
74
+ local key=$1
73
75
 
74
- regex="^($key) *="
75
- output=""
76
+ local regex="^($key) *="
77
+ local output=""
76
78
 
77
79
  config_init
78
80
 
79
81
  while IFS= read -r line || [ -n "$line" ]; do
80
- newline=$line
81
82
  if [[ $line ]] && [[ ! $line =~ $regex ]]; then
82
83
  output="$output$line\n"
83
84
  fi
@@ -100,11 +101,13 @@ config_show() {
100
101
  # done
101
102
  #
102
103
  config_keys() {
103
- regex="^([a-zA-Z0-9_\-\/\.]+) *="
104
+ local regex="^([a-zA-Z0-9_\-\/\.]+) *="
104
105
 
105
106
  config_init
106
107
 
107
- keys=()
108
+ local keys=()
109
+ local key
110
+
108
111
  while IFS= read -r line || [ -n "$line" ]; do
109
112
  if [[ $line =~ $regex ]]; then
110
113
  key="${BASH_REMATCH[1]}"
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.8"
3
3
  end
@@ -1,10 +1,10 @@
1
1
  # :argument.usage
2
2
  echo " <%= name.upcase %>"
3
3
  printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
4
- <%- if allowed -%>
4
+ % if allowed
5
5
  printf " <%= strings[:allowed] % { values: allowed.join(', ') } -%>\n"
6
- <%- end -%>
7
- <%- if default -%>
6
+ % end
7
+ % if default
8
8
  printf " <%= strings[:default] % { value: default } -%>\n"
9
- <%- end -%>
9
+ % end
10
10
  echo
@@ -1,7 +1,7 @@
1
1
  # :command.catch_all_filter
2
- <%- if catch_all_required? -%>
2
+ % if catch_all_required?
3
3
  if [[ ${#other_args[@]} -eq 0 ]]; then
4
4
  printf "<%= strings[:missing_required_argument] % { arg: catch_all_label, usage: usage_string } %>\n"
5
5
  exit 1
6
6
  fi
7
- <%- end -%>
7
+ % end
@@ -1,5 +1,5 @@
1
1
  # :command.command_fallback
2
- <%- if default_command -%>
2
+ % if default_command
3
3
  "" )
4
4
  <%= function_name %>_usage
5
5
  exit 1
@@ -10,7 +10,7 @@
10
10
  <%= default_command.function_name %>_parse_requirements "$@"
11
11
  shift $#
12
12
  ;;
13
- <%- elsif extensible.is_a? String -%>
13
+ % elsif extensible.is_a? String
14
14
  "" )
15
15
  <%= function_name %>_usage
16
16
  exit 1
@@ -23,7 +23,7 @@
23
23
  <%= function_name %>_usage
24
24
  exit 1
25
25
  fi
26
- <%- elsif extensible -%>
26
+ % elsif extensible
27
27
  "" )
28
28
  <%= function_name %>_usage
29
29
  exit 1
@@ -37,9 +37,9 @@
37
37
  <%= function_name %>_usage
38
38
  exit 1
39
39
  fi
40
- <%- else -%>
40
+ % else
41
41
  * )
42
42
  <%= function_name %>_usage
43
43
  exit 1
44
44
  ;;
45
- <%- end -%>
45
+ % end
@@ -1,12 +1,12 @@
1
1
  # :command.command_filter
2
- <%- if commands.any? -%>
2
+ % if commands.any?
3
3
  action=$1
4
4
 
5
5
  case $action in
6
6
  -* )
7
7
  ;;
8
8
 
9
- <%- commands.each do |command| -%>
9
+ % commands.each do |command|
10
10
  <%= command.aliases.join " | " %> )
11
11
  action="<%= command.name %>"
12
12
  shift
@@ -14,9 +14,9 @@ case $action in
14
14
  shift $#
15
15
  ;;
16
16
 
17
- <%- end -%>
17
+ % end
18
18
  <%= render :command_fallback %>
19
19
  esac
20
- <%- else -%>
20
+ % else
21
21
  action="<%= action_name %>"
22
- <%- end -%>
22
+ % end
@@ -1,4 +1,4 @@
1
1
  # :command.command_functions
2
- <%- deep_commands.each do |command| -%>
2
+ % deep_commands.each do |command|
3
3
  <%= command.render :function unless command.commands.any? %>
4
- <%- end -%>
4
+ % end
@@ -1,7 +1,7 @@
1
1
  # :command.default_assignments
2
- <%- default_args.each do |arg| -%>
2
+ % default_args.each do |arg|
3
3
  [[ -n ${args[<%= arg.name %>]} ]] || args[<%= arg.name %>]="<%= arg.default %>"
4
- <%- end -%>
5
- <%- default_flags.each do |flag| -%>
4
+ % end
5
+ % default_flags.each do |flag|
6
6
  [[ -n ${args[<%= flag.long %>]} ]] || args[<%= flag.long %>]="<%= flag.default %>"
7
- <%- end -%>
7
+ % end
@@ -1,9 +1,9 @@
1
1
  # :command.dependencies_filter
2
- <%- if dependencies -%>
3
- <%- dependencies.each do |dependency| -%>
2
+ % if dependencies
3
+ % dependencies.each do |dependency|
4
4
  if ! [[ -x "$(command -v <%= dependency %>)" ]]; then
5
5
  printf "<%= strings[:missing_dependency] % { dependency: dependency } -%>\n"
6
6
  exit 1
7
7
  fi
8
- <%- end -%>
9
- <%- end -%>
8
+ % end
9
+ % end
@@ -1,14 +1,14 @@
1
1
  # :command.environment_variables_filter
2
- <%- if default_environment_variables.any? -%>
3
- <%- default_environment_variables.each do |env_var| -%>
2
+ % if default_environment_variables.any?
3
+ % default_environment_variables.each do |env_var|
4
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| -%>
5
+ % end
6
+ % end
7
+ % if required_environment_variables.any?
8
+ % required_environment_variables.each do |env_var|
9
9
  if [[ -z "$<%= env_var.name.upcase %>" ]]; then
10
- printf "<%= strings[:missing_required_environment_variable] % { var: env_var.name.upcase } -%>\n"
10
+ printf "<%= strings[:missing_required_environment_variable] % { var: env_var.name.upcase } %>\n"
11
11
  exit 1
12
12
  fi
13
- <%- end -%>
14
- <%- end -%>
13
+ % end
14
+ % end
@@ -1,19 +1,19 @@
1
1
  # :command.fixed_flag_filter
2
2
  case "$1" in
3
- <%- if short_flag_exist? "-v" -%>
3
+ % if short_flag_exist? "-v"
4
4
  --version )
5
- <%- else -%>
5
+ % else
6
6
  --version | -v )
7
- <%- end -%>
7
+ % end
8
8
  version_command
9
9
  exit
10
10
  ;;
11
11
 
12
- <%- if short_flag_exist? "-h" -%>
12
+ % if short_flag_exist? "-h"
13
13
  --help )
14
- <%- else -%>
14
+ % else
15
15
  --help | -h )
16
- <%- end -%>
16
+ % end
17
17
  long_usage=yes
18
18
  <%= function_name %>_usage
19
19
  exit
@@ -4,10 +4,5 @@ initialize() {
4
4
  long_usage=''
5
5
  set -e
6
6
 
7
- if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
8
- printf "<%= strings[:unsupported_bash_version] -%>\n"
9
- exit 1
10
- fi
11
-
12
7
  <%= load_user_file("initialize.sh", placeholder: false).indent 2 %>
13
8
  }
@@ -1,6 +1,7 @@
1
1
  <%= render :root_command if commands.empty? %>
2
2
  <%= render :version_command %>
3
3
  <%= render :usage %>
4
+ <%= render :normalize_input %>
4
5
  <%= render :inspect_args %>
5
6
  <%= render :user_lib if user_lib.any? %>
6
7
  <%= render :command_functions %>
@@ -0,0 +1,24 @@
1
+ # :command.normalize_input
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,9 +1,9 @@
1
1
  # :command.parse_requirements
2
- <%- if root_command? -%>
2
+ % if root_command?
3
3
  parse_requirements() {
4
- <%- else -%>
4
+ % else
5
5
  <%= function_name %>_parse_requirements() {
6
- <%- end -%>
6
+ % end
7
7
  <%= render(:fixed_flags_filter).indent 2 %>
8
8
  <%= render(:environment_variables_filter).indent 2 %>
9
9
  <%= render(:dependencies_filter).indent 2 %>
@@ -16,6 +16,6 @@ parse_requirements() {
16
16
  <%= render(:whitelist_filter).indent 2 %>
17
17
  }
18
18
 
19
- <%- commands.each do |command| %>
19
+ % commands.each do |command|
20
20
  <%= command.render :parse_requirements %>
21
- <%- end -%>
21
+ % end
@@ -1,25 +1,25 @@
1
1
  # :command.parse_requirements_case
2
- <%- if args.any? -%>
3
- <%- condition = "if" -%>
4
- <%- args.each do |arg| -%>
2
+ % if args.any?
3
+ % condition = "if"
4
+ % args.each do |arg|
5
5
  <%= condition %> [[ ! ${args[<%= arg.name %>]} ]]; then
6
6
  args[<%= arg.name %>]=$1
7
7
  shift
8
- <%- condition = "elif" -%>
9
- <%- end -%>
8
+ % condition = "elif"
9
+ % end
10
10
  else
11
- <%- if catch_all -%>
11
+ % if catch_all
12
12
  other_args+=("$1")
13
13
  shift
14
- <%- else -%>
14
+ % else
15
15
  printf "<%= strings[:invalid_argument] %>\n" "$key"
16
16
  exit 1
17
- <%- end -%>
17
+ % end
18
18
  fi
19
- <%- elsif catch_all -%>
19
+ % elsif catch_all
20
20
  other_args+=("$1")
21
21
  shift
22
- <%- else -%>
22
+ % else
23
23
  printf "<%= strings[:invalid_argument] %>\n" "$key"
24
24
  exit 1
25
- <%- end -%>
25
+ % end
@@ -2,21 +2,21 @@
2
2
  while [[ $# -gt 0 ]]; do
3
3
  key="$1"
4
4
  case "$key" in
5
- <%- flags.each do |flag| -%>
5
+ % flags.each do |flag|
6
6
  <%= flag.render(:case).indent 2 %>
7
7
 
8
- <%- end -%>
8
+ % end
9
9
 
10
10
  -* )
11
- <%- if catch_all -%>
11
+ % if catch_all
12
12
  other_args+=("$1")
13
13
  shift
14
14
  ;;
15
- <%- else -%>
15
+ % else
16
16
  printf "<%= strings[:invalid_flag] %>\n" "$key"
17
17
  exit 1
18
18
  ;;
19
- <%- end -%>
19
+ % end
20
20
 
21
21
  * )
22
22
  <%= render(:parse_requirements_case).indent 4 %>
@@ -1,5 +1,5 @@
1
1
  # :command.required_args_filter
2
- <%- required_args.each do |arg| -%>
2
+ % required_args.each do |arg|
3
3
  if [[ $1 && $1 != -* ]]; then
4
4
  args[<%= arg.name %>]=$1
5
5
  shift
@@ -8,4 +8,4 @@ else
8
8
  exit 1
9
9
  fi
10
10
 
11
- <%- end %>
11
+ % end
@@ -1,10 +1,10 @@
1
1
  # :command.required_flags_filter
2
- <%- if required_flags.any? -%>
2
+ % if required_flags.any?
3
3
  argstring="$*"
4
- <%- end -%>
5
- <%- required_flags.each do |flag| -%>
4
+ % end
5
+ % required_flags.each do |flag|
6
6
  if [[ <%= flag.aliases.map { |a| %Q["$argstring" != *#{a}*] }.join " && " %> ]]; then
7
7
  printf "<%= strings[:missing_required_flag] % { usage: flag.usage_string } %>\n"
8
8
  exit 1
9
9
  fi
10
- <%- end %>
10
+ % end
@@ -2,7 +2,9 @@
2
2
  run() {
3
3
  declare -A args
4
4
  declare -a other_args
5
- parse_requirements "$@"
5
+ declare -a input
6
+ normalize_input "$@"
7
+ parse_requirements "${input[@]}"
6
8
 
7
9
  <%- condition = "if" -%>
8
10
  <%- deep_commands.each do |command| -%>
@@ -1,14 +1,14 @@
1
1
  # :command.usage_args
2
2
  printf "<%= strings[:arguments] %>\n"
3
- <%- if args.any? -%>
3
+ % if args.any?
4
4
 
5
- <%- args.each do |arg| -%>
5
+ % args.each do |arg|
6
6
  <%= arg.render(:usage) %>
7
- <%- end -%>
8
- <%- end -%>
9
- <%- if catch_all_help -%>
7
+ % end
8
+ % end
9
+ % if catch_all_help
10
10
 
11
11
  echo " <%= catch_all_label %>"
12
12
  printf "<%= catch_all_help.wrap(76).indent(4).sanitize_for_print %>\n"
13
13
  echo
14
- <%- end -%>
14
+ % end
@@ -1,18 +1,18 @@
1
1
  # :command.usage_commands
2
- <%- unless commands.first.group -%>
2
+ % unless commands.first.group
3
3
  printf "<%= strings[:commands] %>\n"
4
- <%- end -%>
5
- <%- maxlen = command_names.map(&:size).max -%>
6
- <%- commands.each do |command| -%>
7
- <%- summary = command.summary -%>
8
- <%- summary = strings[:default_command_summary] % { summary: summary } if command.default -%>
9
- <%- if command.group -%>
10
- <%- if command.name == commands.first.name -%>
4
+ % end
5
+ % maxlen = command_names.map(&:size).max
6
+ % commands.each do |command|
7
+ % summary = command.summary
8
+ % summary = strings[:default_command_summary] % { summary: summary } if command.default
9
+ % if command.group
10
+ % if command.name == commands.first.name
11
11
  printf "<%= strings[:group] % { group: command.group } %>\n"
12
- <%- else -%>
12
+ % else
13
13
  printf "\n<%= strings[:group] % { group: command.group } %>\n"
14
- <%- end -%>
15
- <%- end -%>
14
+ % end
15
+ % end
16
16
  echo " <%= command.name.ljust maxlen %> <%= summary %>"
17
- <%- end -%>
17
+ % end
18
18
  echo
@@ -1,6 +1,6 @@
1
1
  # :command.usage_environment_variables
2
2
  printf "<%= strings[:environment_variables] %>\n"
3
3
 
4
- <%- environment_variables.each do |env_var| -%>
4
+ % environment_variables.each do |env_var|
5
5
  <%= env_var.render(:usage) %>
6
- <%- end -%>
6
+ % end
@@ -1,7 +1,7 @@
1
1
  # :command.usage_examples
2
2
  printf "<%= strings[:examples] %>\n"
3
3
 
4
- <%- examples.each do |example| -%>
4
+ % examples.each do |example|
5
5
  printf "<%= example.wrap(78).indent(2).sanitize_for_print %>\n"
6
- <%- end -%>
6
+ % end
7
7
  echo
@@ -1,17 +1,17 @@
1
1
  # :command.usage_fixed_flags
2
- <%- if short_flag_exist? "-h" -%>
2
+ % if short_flag_exist? "-h"
3
3
  echo " --help"
4
- <%- else -%>
4
+ % else
5
5
  echo " --help, -h"
6
- <%- end -%>
6
+ % end
7
7
  printf " <%= strings[:help_flag_text] %>\n"
8
8
  echo
9
- <%- if root_command? -%>
10
- <%- if short_flag_exist? "-v" -%>
9
+ % if root_command?
10
+ % if short_flag_exist? "-v"
11
11
  echo " --version"
12
- <%- else -%>
12
+ % else
13
13
  echo " --version, -v"
14
- <%- end -%>
14
+ % end
15
15
  printf " <%= strings[:version_flag_text] %>\n"
16
16
  echo
17
- <%- end -%>
17
+ % end
@@ -1,4 +1,4 @@
1
1
  # :command.usage_flags
2
- <%- flags.each do |flag| -%>
2
+ % flags.each do |flag|
3
3
  <%= flag.render(:usage) %>
4
- <%- end -%>
4
+ % end
@@ -1,6 +1,6 @@
1
1
  # :command.user_lib
2
- <%- user_lib.each do |file| -%>
2
+ % user_lib.each do |file|
3
3
  # <%= ":#{file}" %>
4
4
  <%= File.read file %>
5
5
 
6
- <%- end -%>
6
+ % end
@@ -1,13 +1,13 @@
1
1
  # :command.whitelist_filter
2
- <%- whitelisted_args.each do |arg| -%>
2
+ % whitelisted_args.each do |arg|
3
3
  if [[ ! ${args[<%= arg.name %>]} =~ ^(<%= arg.allowed.join '|' %>)$ ]]; then
4
4
  printf "%s\n" "<%= strings[:disallowed_argument] % { name: arg.name, allowed: arg.allowed.join(', ') } %>"
5
5
  exit 1
6
6
  fi
7
- <%- end -%>
8
- <%- whitelisted_flags.each do |flag| -%>
7
+ % end
8
+ % whitelisted_flags.each do |flag|
9
9
  if [[ ! ${args[<%= flag.name %>]} =~ ^(<%= flag.allowed.join '|' %>)$ ]]; then
10
10
  printf "%s\n" "<%= strings[:disallowed_flag] % { name: flag.name, allowed: flag.allowed.join(', ') } %>"
11
11
  exit 1
12
12
  fi
13
- <%- end -%>
13
+ % end
@@ -1,7 +1,7 @@
1
1
  # :environment_variable.usage
2
2
  echo " <%= usage_string extended: true %>"
3
3
  printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
4
- <%- if default -%>
4
+ % if default
5
5
  printf " <%= strings[:default] % { value: default } -%>\n"
6
- <%- end -%>
6
+ % end
7
7
  echo
@@ -1,6 +1,6 @@
1
1
  # :flag.case
2
2
  <%= aliases.join " | " %> )
3
- <%- if arg -%>
3
+ % if arg
4
4
  if [[ $2 ]]; then
5
5
  args[<%= name %>]="$2"
6
6
  shift
@@ -9,8 +9,8 @@
9
9
  printf "%s\n" "<%= strings[:flag_requires_an_argument] % { name: name, usage: usage_string } %>"
10
10
  exit 1
11
11
  fi
12
- <%- else -%>
12
+ % else
13
13
  args[<%= name %>]=1
14
14
  shift
15
- <%- end -%>
15
+ % end
16
16
  ;;
@@ -1,10 +1,10 @@
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 allowed -%>
4
+ % if allowed
5
5
  printf " <%= strings[:allowed] % { values: allowed.join(', ') } -%>\n"
6
- <%- end -%>
7
- <%- if default -%>
6
+ % end
7
+ % if default
8
8
  printf " <%= strings[:default] % { value: default } -%>\n"
9
- <%- end -%>
9
+ % end
10
10
  echo
@@ -0,0 +1,5 @@
1
+ # :script.bash3_bouncer
2
+ if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
3
+ printf "<%= strings[:unsupported_bash_version] -%>\n"
4
+ exit 1
5
+ fi
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
  # This script was generated by bashly (https://github.com/DannyBen/bashly)
3
3
  # Modifying it manually is not recommended
4
+
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.6.4
4
+ version: 0.6.8
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-08-27 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -30,20 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.1.2
33
+ version: '0.2'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '0.1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.1.2
40
+ version: '0.2'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: mister_bin
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,6 +122,7 @@ files:
128
122
  - lib/bashly/views/command/initialize.erb
129
123
  - lib/bashly/views/command/inspect_args.erb
130
124
  - lib/bashly/views/command/master_script.erb
125
+ - lib/bashly/views/command/normalize_input.erb
131
126
  - lib/bashly/views/command/parse_requirements.erb
132
127
  - lib/bashly/views/command/parse_requirements_case.erb
133
128
  - lib/bashly/views/command/parse_requirements_while.erb
@@ -148,12 +143,17 @@ files:
148
143
  - lib/bashly/views/environment_variable/usage.erb
149
144
  - lib/bashly/views/flag/case.erb
150
145
  - lib/bashly/views/flag/usage.erb
146
+ - lib/bashly/views/script/bash3_bouncer.erb
151
147
  - lib/bashly/views/script/header.erb
152
148
  - lib/bashly/views/script/wrapper.erb
153
149
  homepage: https://github.com/dannyben/bashly
154
150
  licenses:
155
151
  - MIT
156
- metadata: {}
152
+ metadata:
153
+ bug_tracker_uri: https://github.com/DannyBen/bashly/issues
154
+ changelog_uri: https://github.com/DannyBen/bashly/blob/master/CHANGELOG.md
155
+ homepage_uri: https://bashly.dannyb.co/
156
+ source_code_uri: https://github.com/DannyBen/bashly
157
157
  post_install_message:
158
158
  rdoc_options: []
159
159
  require_paths: