bashly 0.3.1 → 0.3.2

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: 457aceee843507aa8834ede40e17d0ede1bfdfadea943688d5d74277bdee1446
4
- data.tar.gz: 56b445b5d0517045e5deafbd994bce1ef5cf60b8fae536bd522a53d82bf20bf4
3
+ metadata.gz: 665f22f00a1ebc72e1d6e549cfea6030410a386a9375f39734a00e4091290e89
4
+ data.tar.gz: 7e2a7b0afb183f1103d7a789fa6955e7520b63505130e764b91b14a3d3e15235
5
5
  SHA512:
6
- metadata.gz: 00f9df5aa5d43035267d49ec83ccfff4225f8866da6b350ee085d42e968ab04739feacbcf6e85a5d105f6c40ccc504f1be6bc2423a87c96c2a740157f6fd8fd6
7
- data.tar.gz: d372d3e369e6d3a3e54a6630285db36251b89149717813248e1370ee9f2ec93ea98d594addc68e1499174e2b48a0c1bc67a9c7c437b7f71abe4fd7e80651c02e
6
+ metadata.gz: 77d14c4d2ce85b462aea89a4cce5aadef3bf70ca6373bf782b58bedcf17fcd52d2fbe2bfd26569d9c0a03fecea2a1eec8c630eec51003438bdf8fe099b28bf3e
7
+ data.tar.gz: c6b803f2390630053483ca5507df869c95f0fa50752d3f3cf9595807a5779b01724c99460ee8bf0c5a258959769100199a5876bafe62430189e925d697abd979
@@ -18,7 +18,7 @@ module Bashly
18
18
  command "colors", "Add standard functions for printing colorful and formatted text to the lib directory."
19
19
  command "yaml", "Add standard functions for reading YAML files to the lib directory."
20
20
 
21
- environment "BASHLY_SOURCE_DIR", "The path to use for creating the configuration file [default: src]"
21
+ environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
22
22
 
23
23
  def strings_command
24
24
  safe_copy asset("templates/strings.yml"), "#{Settings.source_dir}/bashly-strings.yml"
@@ -8,7 +8,7 @@ module Bashly
8
8
 
9
9
  option "-f --force", "Overwrite existing files"
10
10
 
11
- environment "BASHLY_SOURCE_DIR", "The path to use for creating the configuration file [default: src]"
11
+ environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
12
12
  environment "BASHLY_TARGET_DIR", "The path to use for creating the bash script [default: .]"
13
13
 
14
14
  def run
@@ -10,23 +10,23 @@
10
10
  #
11
11
  # ---
12
12
 
13
- red() { echo -e "\e[31m$*\e[0m" ; }
14
- green() { echo -e "\e[32m$*\e[0m" ; }
15
- yellow() { echo -e "\e[33m$*\e[0m" ; }
16
- blue() { echo -e "\e[34m$*\e[0m" ; }
17
- magenta() { echo -e "\e[35m$*\e[0m" ; }
18
- cyan() { echo -e "\e[36m$*\e[0m" ; }
19
- bold() { echo -e "\e[1m$*\e[0m" ; }
20
- underlined() { echo -e "\e[4m$*\e[0m" ; }
21
- red_bold() { echo -e "\e[1;31m$*\e[0m" ; }
22
- green_bold() { echo -e "\e[1;32m$*\e[0m" ; }
23
- yellow_bold() { echo -e "\e[1;33m$*\e[0m" ; }
24
- blue_bold() { echo -e "\e[1;34m$*\e[0m" ; }
25
- magenta_bold() { echo -e "\e[1;35m$*\e[0m" ; }
26
- cyan_bold() { echo -e "\e[1;36m$*\e[0m" ; }
27
- red_underlined() { echo -e "\e[4;31m$*\e[0m" ; }
28
- green_underlined() { echo -e "\e[4;32m$*\e[0m" ; }
29
- yellow_underlined() { echo -e "\e[4;33m$*\e[0m" ; }
30
- blue_underlined() { echo -e "\e[4;34m$*\e[0m" ; }
31
- magenta_underlined() { echo -e "\e[4;35m$*\e[0m" ; }
32
- cyan_underlined() { echo -e "\e[4;36m$*\e[0m" ; }
13
+ red() { printf "\e[31m%b\e[0m\n" "$*"; }
14
+ green() { printf "\e[32m%b\e[0m\n" "$*"; }
15
+ yellow() { printf "\e[33m%b\e[0m\n" "$*"; }
16
+ blue() { printf "\e[34m%b\e[0m\n" "$*"; }
17
+ magenta() { printf "\e[35m%b\e[0m\n" "$*"; }
18
+ cyan() { printf "\e[36m%b\e[0m\n" "$*"; }
19
+ bold() { printf "\e[1m%b\e[0m\n" "$*"; }
20
+ underlined() { printf "\e[4m%b\e[0m\n" "$*"; }
21
+ red_bold() { printf "\e[1;31m%b\e[0m\n" "$*"; }
22
+ green_bold() { printf "\e[1;32m%b\e[0m\n" "$*"; }
23
+ yellow_bold() { printf "\e[1;33m%b\e[0m\n" "$*"; }
24
+ blue_bold() { printf "\e[1;34m%b\e[0m\n" "$*"; }
25
+ magenta_bold() { printf "\e[1;35m%b\e[0m\n" "$*"; }
26
+ cyan_bold() { printf "\e[1;36m%b\e[0m\n" "$*"; }
27
+ red_underlined() { printf "\e[4;31m%b\e[0m\n" "$*"; }
28
+ green_underlined() { printf "\e[4;32m%b\e[0m\n" "$*"; }
29
+ yellow_underlined() { printf "\e[4;33m%b\e[0m\n" "$*"; }
30
+ blue_underlined() { printf "\e[4;34m%b\e[0m\n" "$*"; }
31
+ magenta_underlined() { printf "\e[4;35m%b\e[0m\n" "$*"; }
32
+ cyan_underlined() { printf "\e[4;36m%b\e[0m\n" "$*"; }
@@ -63,7 +63,7 @@ config_set() {
63
63
  output="$output$key = $value\n"
64
64
  fi
65
65
 
66
- echo -e "$output" > "$CONFIG_FILE"
66
+ printf "%b\n" "$output" > "$CONFIG_FILE"
67
67
  }
68
68
 
69
69
  # Delete a key from teh config.
@@ -83,7 +83,7 @@ config_del() {
83
83
  fi
84
84
  done < "$CONFIG_FILE"
85
85
 
86
- echo -e "$output" > "$CONFIG_FILE"
86
+ printf "%b\n" "$output" > "$CONFIG_FILE"
87
87
  }
88
88
 
89
89
  # Show the config file
@@ -12,8 +12,8 @@ version_flag_text: Show version number
12
12
 
13
13
  # Error messages
14
14
  flag_requires_an_argument: "%{long} requires an argument: %{usage}"
15
- invalid_argument: "invalid argument: %{arg}"
16
- invalid_flag: "invalid option: %{flag}"
15
+ invalid_argument: "invalid argument: %s"
16
+ invalid_flag: "invalid option: %s"
17
17
  missing_required_argument: "missing required argument: %{arg}\\nusage: %{usage}"
18
18
  missing_required_flag: "missing required flag: %{usage}"
19
19
  missing_required_environment_variable: "missing required environment variable: %{var}"
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -1,4 +1,4 @@
1
1
  # :argument.usage
2
2
  echo " <%= name.upcase %>"
3
- echo -e "<%= help.wrap(76).indent(4).sanitize_for_print %>"
3
+ printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
4
4
  echo
@@ -2,7 +2,7 @@
2
2
  <%- if dependencies -%>
3
3
  <%- dependencies.each do |dependency| -%>
4
4
  if ! [[ -x "$(command -v <%= dependency %>)" ]]; then
5
- echo -e "<%= strings[:missing_dependency] % { dependency: dependency } -%>"
5
+ printf "<%= strings[:missing_dependency] % { dependency: dependency } -%>\n"
6
6
  exit 1
7
7
  fi
8
8
  <%- end -%>
@@ -2,7 +2,7 @@
2
2
  <%- if required_environment_variables.any? -%>
3
3
  <%- required_environment_variables.each do |env_var| -%>
4
4
  if [[ -z "$<%= env_var.name.upcase %>" ]]; then
5
- echo -e "<%= strings[:missing_required_environment_variable] % { var: env_var.name.upcase } -%>"
5
+ printf "<%= strings[:missing_required_environment_variable] % { var: env_var.name.upcase } -%>\n"
6
6
  exit 1
7
7
  fi
8
8
  <%- end -%>
@@ -8,10 +8,10 @@
8
8
  <%- condition = "elif" -%>
9
9
  <%- end -%>
10
10
  else
11
- echo -e "<%= strings[:invalid_argument] % { arg: "$key" } %>"
11
+ printf "<%= strings[:invalid_argument] %>\n" "$key"
12
12
  exit 1
13
13
  fi
14
14
  <%- else -%>
15
- echo -e "<%= strings[:invalid_argument] % { arg: "$key" } %>"
15
+ printf "<%= strings[:invalid_argument] %>\n" "$key"
16
16
  exit 1
17
17
  <%- end -%>
@@ -8,7 +8,7 @@ while [[ $# -gt 0 ]]; do
8
8
  <%- end -%>
9
9
 
10
10
  -* )
11
- echo -e "<%= strings[:invalid_flag] % { flag: "$key" } %>"
11
+ printf "<%= strings[:invalid_flag] %>\n" "$key"
12
12
  exit 1
13
13
  ;;
14
14
 
@@ -4,7 +4,7 @@ if [[ $1 && $1 != -* ]]; then
4
4
  args[<%= arg.name %>]=$1
5
5
  shift
6
6
  else
7
- echo -e "<%= strings[:missing_required_argument] % { arg: arg.name.upcase, usage: usage_string } %>"
7
+ printf "<%= strings[:missing_required_argument] % { arg: arg.name.upcase, usage: usage_string } %>\n"
8
8
  exit 1
9
9
  fi
10
10
 
@@ -4,7 +4,7 @@ argstring="$*"
4
4
  <%- end -%>
5
5
  <%- required_flags.each do |flag| -%>
6
6
  if [[ <%= flag.aliases.map { |a| %Q["$argstring" != *#{a}*] }.join " && " %> ]]; then
7
- echo -e "<%= strings[:missing_required_flag] % { usage: flag.usage_string } %>"
7
+ printf "<%= strings[:missing_required_flag] % { usage: flag.usage_string } %>\n"
8
8
  exit 1
9
9
  fi
10
10
  <%- end %>
@@ -2,33 +2,33 @@
2
2
  <%= function_name %>_usage() {
3
3
  if [[ -n $long_usage ]]; then
4
4
  <%- if summary == help -%>
5
- echo -e "<%= caption_string %>"
5
+ printf "<%= caption_string %>\n"
6
6
  echo
7
7
  <%- else -%>
8
- echo -e "<%= full_name %>"
8
+ printf "<%= full_name %>\n"
9
9
  echo
10
- echo -e "<%= help.wrap(78).indent(2).sanitize_for_print %>"
10
+ printf "<%= help.wrap(78).indent(2).sanitize_for_print %>\n"
11
11
  echo
12
12
  <%- end -%>
13
13
  else
14
- echo -e "<%= caption_string %>"
14
+ printf "<%= caption_string %>\n"
15
15
  echo
16
16
  fi
17
- echo -e "<%= strings[:usage] %>"
18
- echo -e " <%= usage_string %>"
17
+ printf "<%= strings[:usage] %>\n"
18
+ printf " <%= usage_string %>\n"
19
19
  <%- if commands.any? -%>
20
- echo -e " <%= full_name %> [command] --help | -h"
20
+ printf " <%= full_name %> [command] --help | -h\n"
21
21
  <%- else -%>
22
- echo -e " <%= full_name %> --help | -h"
22
+ printf " <%= full_name %> --help | -h\n"
23
23
  <%- end -%>
24
24
  <%- if root_command? -%>
25
- echo -e " <%= full_name %> --version"
25
+ printf " <%= full_name %> --version\n"
26
26
  <%- end -%>
27
27
  echo
28
28
  <%= render(:usage_commands).indent 2 if commands.any? %>
29
29
 
30
30
  if [[ -n $long_usage ]]; then
31
- echo -e "<%= strings[:options] %>"
31
+ printf "<%= strings[:options] %>\n"
32
32
  <%= render(:usage_fixed_flags).indent 4 %>
33
33
  <%= render(:usage_flags).indent 4 if flags.any? %>
34
34
  <%= render(:usage_args).indent 4 if args.any? %>
@@ -1,5 +1,5 @@
1
1
  # :command.usage_args
2
- echo -e "<%= strings[:arguments] %>"
2
+ printf "<%= strings[:arguments] %>\n"
3
3
 
4
4
  <%- args.each do |arg| -%>
5
5
  <%= arg.render(:usage) %>
@@ -1,5 +1,5 @@
1
1
  # :command.usage_commands
2
- echo -e "<%= strings[:commands] %>"
2
+ printf "<%= strings[:commands] %>\n"
3
3
  <%- maxlen = command_names.map(&:size).max -%>
4
4
  <%- commands.each do |command| -%>
5
5
  <%- summary = command.summary -%>
@@ -1,5 +1,5 @@
1
1
  # :command.usage_environment_variables
2
- echo -e "<%= strings[:environment_variables] %>"
2
+ printf "<%= strings[:environment_variables] %>\n"
3
3
 
4
4
  <%- environment_variables.each do |env_var| -%>
5
5
  <%= env_var.render(:usage) %>
@@ -1,7 +1,7 @@
1
1
  # :command.usage_examples
2
- echo -e "<%= strings[:examples] %>"
2
+ printf "<%= strings[:examples] %>\n"
3
3
 
4
4
  <%- examples.each do |example| -%>
5
- echo -e "<%= example.wrap(78).indent(2).sanitize_for_print %>"
5
+ printf "<%= example.wrap(78).indent(2).sanitize_for_print %>\n"
6
6
  <%- end -%>
7
7
  echo
@@ -1,9 +1,9 @@
1
1
  # :command.usage_fixed_flags
2
2
  echo " --help, -h"
3
- echo -e " <%= strings[:help_flag_text] %>"
3
+ printf " <%= strings[:help_flag_text] %>\n"
4
4
  echo
5
5
  <%- if root_command? -%>
6
6
  echo " --version"
7
- echo -e " <%= strings[:version_flag_text] %>"
7
+ printf " <%= strings[:version_flag_text] %>\n"
8
8
  echo
9
9
  <%- end -%>
@@ -1,4 +1,4 @@
1
1
  # :environment_variable.usage
2
2
  echo " <%= usage_string extended: true %>"
3
- echo -e "<%= help.wrap(76).indent(4).sanitize_for_print %>"
3
+ printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
4
4
  echo
@@ -6,7 +6,7 @@
6
6
  shift
7
7
  shift
8
8
  else
9
- echo -e "<%= strings[:flag_requires_an_argument] % { long: long, usage: usage_string } %>"
9
+ printf "<%= strings[:flag_requires_an_argument] % { long: long, usage: usage_string } %>\n"
10
10
  exit 1
11
11
  fi
12
12
  <%- else -%>
@@ -1,4 +1,4 @@
1
1
  # :flag.usage
2
2
  echo " <%= usage_string extended: true %>"
3
- echo -e "<%= help.wrap(76).indent(4).sanitize_for_print %>"
3
+ printf "<%= help.wrap(76).indent(4).sanitize_for_print %>\n"
4
4
  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.1
4
+ version: 0.3.2
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-11-29 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole