bashly 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c0cd0da5f37edbad28313553ac30b878edae7d2255158d940af0deb8aa0a05
4
- data.tar.gz: 6cf9bac796564e7730f3a55e6022d78a962506b418eb00cdecbe1111f3770ffb
3
+ metadata.gz: 2b90c79b66c9396dc7fda026e19761818e7db33c8b19b0e0501486b3cdf7f1e0
4
+ data.tar.gz: be2b5e3ae996189263e604421910ebc3b8a597e3cf9c525cf19b94e2e4434fd3
5
5
  SHA512:
6
- metadata.gz: 16eb355eb439bfc24457b184dd8255c091bb62dc1646c15e6d2842160f8848595de799cb453e54e43cdf5c2605906ed8f8c49ee21f5afda3999c9224b8d6fbc6
7
- data.tar.gz: 889722479c576c8b30c3be1081911d0a7f61613664fc146fb4a2867b65d7199a5283464cc59eb40530e2c43f8270fbaa11e7f3a3d851cedc87a71515aef235b8
6
+ metadata.gz: 1414d602e5fabf5e9b98dfb1811276601f01de83dc0c866ce155ab22a2246122c9a6a2605c9f83dedc70f21a47c5f397b5ed59339412d8eccf09a319429b7271
7
+ data.tar.gz: 8bef6713c24b2a2d24d0ef97b54c1fd957ad8ff28e041ec08fdfa96c3bedc22a5a41c6b4691367357e63e404ba87dbd9599d7eddd0102cbe9bac9184f0d1dcee
data/README.md CHANGED
@@ -29,7 +29,12 @@ a [docker image](https://hub.docker.com/r/dannyben/bashly).
29
29
 
30
30
  ## Bashly is Sponsored By
31
31
 
32
- <a href="https://rhodecode.com/"><img src='support/img/RhodeCode-logo.png' width=280></a>
32
+ <table>
33
+ <tr>
34
+ <td><a href="https://rhodecode.com/"><img src='support/img/RhodeCode-logo.png' width=240></a></td>
35
+ <td><a href="https://decisiohealth.com/"><img src='support/img/decisio-logo.png' width=240></a></td>
36
+ </tr>
37
+ </table>
33
38
 
34
39
 
35
40
  ## Documentation
@@ -69,7 +74,7 @@ Bashly is responsible for:
69
74
  - **Bash completions**.
70
75
  - and more.
71
76
 
72
- ## Contributing / Support
77
+ ## Contributing / Support
73
78
 
74
79
  If you experience any issue, have a question or a suggestion, or if you wish
75
80
  to contribute, feel free to [open an issue][issues] or
@@ -75,7 +75,7 @@ module Bashly
75
75
  def raw_data
76
76
  @raw_data ||= begin
77
77
  result = {}
78
- Dir["#{docs_dir}/*.yml"].sort.each do |path|
78
+ Dir["#{docs_dir}/*.yml"].each do |path|
79
79
  result.merge! YAML.load_file(path)
80
80
  end
81
81
  result
@@ -89,7 +89,7 @@ module Bashly
89
89
  end
90
90
 
91
91
  def generated_files
92
- Dir["#{Settings.source_dir}/**/*.*"].sort
92
+ Dir["#{Settings.source_dir}/**/*.*"]
93
93
  end
94
94
 
95
95
  def upgrade(existing_file, library_name, *args)
@@ -125,9 +125,6 @@ module Bashly
125
125
  def create_user_files
126
126
  quiet_say "creating user files in g`#{Settings.source_dir}`"
127
127
 
128
- create_file "#{Settings.source_dir}/initialize.#{Settings.partials_extension}",
129
- command.render(:default_initialize_script)
130
-
131
128
  if command.commands.empty?
132
129
  create_root_command_file
133
130
  else
@@ -100,14 +100,14 @@ module Bashly
100
100
 
101
101
  refute value['name'].match(/^-/), "#{key}.name must not start with '-'"
102
102
 
103
- refute value['required'] && value['default'], "#{key} cannot have both required and default"
103
+ refute value['required'] && value['default'], "#{key} cannot have both nub`required` and nub`default`"
104
104
  end
105
105
 
106
106
  def assert_flag(key, value)
107
107
  assert_hash key, value, keys: Script::Flag.option_keys
108
- assert value['short'] || value['long'], "#{key} must have at least one of long or short name"
108
+ assert value['short'] || value['long'], "#{key} must have at least one of nub`long` or nub`short`"
109
109
 
110
- refute value['allowed'] && value['completions'], "#{key} cannot have both allowed and completions"
110
+ refute value['allowed'] && value['completions'], "#{key} cannot have both nub`allowed` and nub`completions`"
111
111
 
112
112
  assert_optional_string "#{key}.long", value['long']
113
113
  assert_optional_string "#{key}.short", value['short']
@@ -127,18 +127,18 @@ module Bashly
127
127
  assert value['short'].match(/^-[a-zA-Z0-9]$/), "#{key}.short must be in the form of '-n'" if value['short']
128
128
  refute value['arg'].match(/^-/), "#{key}.arg must not start with '-'" if value['arg']
129
129
 
130
- refute value['required'] && value['default'], "#{key} cannot have both required and default"
130
+ refute value['required'] && value['default'], "#{key} cannot have both nub`required` and nub`default`"
131
131
 
132
132
  if value['default']
133
- assert value['arg'], "#{key}.default does not make sense without arg"
133
+ assert value['arg'], "#{key}.default does not make sense without nub`arg`"
134
134
  end
135
135
 
136
136
  if value['allowed']
137
- assert value['arg'], "#{key}.allowed does not make sense without arg"
137
+ assert value['arg'], "#{key}.allowed does not make sense without nub`arg`"
138
138
  end
139
139
 
140
140
  if value['completions']
141
- assert value['arg'], "#{key}.completions does not make sense without arg"
141
+ assert value['arg'], "#{key}.completions does not make sense without nub`arg`"
142
142
  end
143
143
  end
144
144
 
@@ -154,8 +154,8 @@ module Bashly
154
154
  def assert_command(key, value)
155
155
  assert_hash key, value, keys: Script::Command.option_keys
156
156
 
157
- refute value['commands'] && value['args'], "#{key} cannot have both commands and args"
158
- refute value['commands'] && value['catch_all'], "#{key} cannot have both commands and catch_all"
157
+ refute value['commands'] && value['args'], "#{key} cannot have both nub`commands` and nub`args`"
158
+ refute value['commands'] && value['catch_all'], "#{key} cannot have both nub`commands` and nub`catch_all`"
159
159
 
160
160
  assert_string "#{key}.name", value['name']
161
161
  assert_optional_string "#{key}.help", value['help']
@@ -202,7 +202,7 @@ module Bashly
202
202
  end
203
203
 
204
204
  if value['expose']
205
- assert value['commands'], "#{key}.expose makes no sense without commands"
205
+ assert value['commands'], "#{key}.expose makes no sense without nub`commands`"
206
206
  end
207
207
 
208
208
  if key == 'root'
@@ -0,0 +1,6 @@
1
+ ## initialize hook
2
+ ##
3
+ ## Any code here will be placed inside the `initialize()` function and called
4
+ ## before running anything else.
5
+ ##
6
+ ## You can safely delete this file if you do not need it.
@@ -30,8 +30,10 @@ help:
30
30
  handler: Bashly::Libraries::Help
31
31
 
32
32
  hooks:
33
- help: Add placeholders for before/after hooks which are executed before/after any command.
33
+ help: Add placeholders for initialize/before/after hooks which are executed on script initialization, and before/after any command.
34
34
  files:
35
+ - source: "hooks/initialize.sh"
36
+ target: "%{user_source_dir}/initialize.%{user_ext}"
35
37
  - source: "hooks/before.sh"
36
38
  target: "%{user_source_dir}/before.%{user_ext}"
37
39
  - source: "hooks/after.sh"
@@ -297,7 +297,7 @@ module Bashly
297
297
  # This is meant to provide the user with the ability to add custom
298
298
  # functions
299
299
  def user_lib
300
- @user_lib ||= Dir["#{Settings.full_lib_dir}/**/*.#{Settings.partials_extension}"].sort
300
+ @user_lib ||= Dir["#{Settings.full_lib_dir}/**/*.#{Settings.partials_extension}"]
301
301
  end
302
302
 
303
303
  # Returns an array of all the args with a whitelist
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -6,7 +6,7 @@ if default_args.any? or default_flags.any?
6
6
  end
7
7
 
8
8
  default_flags.each do |flag|
9
- > [[ -n ${args['{{ flag.long }}']:-} ]] || args['{{ flag.long }}']="{{ flag.default }}"
9
+ > [[ -n ${args['{{ flag.name }}']:-} ]] || args['{{ flag.name }}']="{{ flag.default }}"
10
10
  end
11
11
 
12
12
  >
@@ -4,4 +4,4 @@ if default_environment_variables.any?
4
4
  default_environment_variables.each do |env_var|
5
5
  > export {{ env_var.name.upcase }}="${<%= env_var.name.upcase %>:-<%= env_var.default %>}"
6
6
  end
7
- end
7
+ end
@@ -4,13 +4,16 @@
4
4
  > version="<%= version %>"
5
5
  > long_usage=''
6
6
  > {{ Settings.strict_string }}
7
- >
8
7
 
9
8
  if root_command?
9
+ >
10
10
  = render(:environment_variables_default).indent 2
11
11
  end
12
12
 
13
- = load_user_file("initialize", placeholder: false).indent 2
13
+ if user_file_exist?('initialize')
14
+ >
15
+ = load_user_file('initialize').indent 2
16
+ end
14
17
 
15
18
  > }
16
19
  >
@@ -2,7 +2,7 @@ if required_flags.any?
2
2
  = view_marker
3
3
 
4
4
  required_flags.each do |flag|
5
- > if [[ -z ${args['{{ flag.long }}']+x} ]]; then
5
+ > if [[ -z ${args['{{ flag.name }}']+x} ]]; then
6
6
  > printf "{{ strings[:missing_required_flag] % { usage: flag.usage_string } }}\n" >&2
7
7
  > exit 1
8
8
  > fi
@@ -12,7 +12,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
12
12
  > done
13
13
 
14
14
  else
15
- > if [[ ! ${args['{{ arg.name }}']} =~ ^({{ arg.allowed.join '|' }})$ ]]; then
15
+ > if [[ -n ${args['{{ arg.name }}']} ]] && [[ ! ${args['{{ arg.name }}']} =~ ^({{ arg.allowed.join '|' }})$ ]]; then
16
16
  > printf "%s\n" "{{ strings[:disallowed_argument] % { name: arg.name, allowed: arg.allowed.join(', ') } }}" >&2
17
17
  > exit 1
18
18
  > fi
@@ -31,7 +31,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
31
31
  > done
32
32
 
33
33
  else
34
- > if [[ ! ${args['{{ flag.name }}']} =~ ^({{ flag.allowed.join '|' }})$ ]]; then
34
+ > if [[ ${args['{{ flag.name }}']} ]] && [[ ! ${args['{{ flag.name }}']} =~ ^({{ flag.allowed.join '|' }})$ ]]; then
35
35
  > printf "%s\n" "{{ strings[:disallowed_flag] % { name: flag.name, allowed: flag.allowed.join(', ') } }}" >&2
36
36
  > exit 1
37
37
  > fi
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: 1.0.2
4
+ version: 1.0.3
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: 2023-03-23 00:00:00.000000000 Z
11
+ date: 2023-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -157,6 +157,7 @@ files:
157
157
  - lib/bashly/libraries/help/help_command.sh
158
158
  - lib/bashly/libraries/hooks/after.sh
159
159
  - lib/bashly/libraries/hooks/before.sh
160
+ - lib/bashly/libraries/hooks/initialize.sh
160
161
  - lib/bashly/libraries/lib/sample_function.sh
161
162
  - lib/bashly/libraries/libraries.yml
162
163
  - lib/bashly/libraries/settings/settings.yml
@@ -192,7 +193,6 @@ files:
192
193
  - lib/bashly/views/command/command_filter.gtx
193
194
  - lib/bashly/views/command/command_functions.gtx
194
195
  - lib/bashly/views/command/default_assignments.gtx
195
- - lib/bashly/views/command/default_initialize_script.gtx
196
196
  - lib/bashly/views/command/default_root_script.gtx
197
197
  - lib/bashly/views/command/default_script.gtx
198
198
  - lib/bashly/views/command/dependencies_filter.gtx
@@ -255,14 +255,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - ">="
257
257
  - !ruby/object:Gem::Version
258
- version: 2.7.0
258
+ version: '3.0'
259
259
  required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  requirements:
261
261
  - - ">="
262
262
  - !ruby/object:Gem::Version
263
263
  version: '0'
264
264
  requirements: []
265
- rubygems_version: 3.4.8
265
+ rubygems_version: 3.4.10
266
266
  signing_key:
267
267
  specification_version: 4
268
268
  summary: Bash Command Line Tool Generator
@@ -1,7 +0,0 @@
1
- > ## Code here runs inside the initialize() function
2
- > ## Use it for anything that you need to run before any other function, like
3
- > ## setting environment variables:
4
- > ## CONFIG_FILE=settings.ini
5
- > ##
6
- > ## Feel free to empty (but not delete) this file.
7
- >