bashly 0.8.7 → 0.8.9

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: '09fd56d9f65d2a7859382562739364338cbe7ccf52d2c82ac446f3e9b6a5d118'
4
- data.tar.gz: 10a648ebf0552b376cca8aa1ff89592670721c089acea84c10ff3aeaacd218e3
3
+ metadata.gz: df22bc90e5ea6fa9878280dfdafbd39614e11ca6c8d6db1cda17b838518033e8
4
+ data.tar.gz: 5633f2f1c7f06a9c3adf75db634cf0b045be7d743bfd6829bc3fa4ab9843ea71
5
5
  SHA512:
6
- metadata.gz: 65c59416204a5c3a7da38efad9373ac555e2368fbdd27b47e4e7d3b143abe73f4c22309b0d6f8909b00f70807b9502095ec10728a8f903738e24f300d75e52f7
7
- data.tar.gz: fe3a5db484a8cf4af117fc43114095acbbfb96c25ed1f63570029981ca175d6d6bd7e89a42cef8bbc2eedeff6aa5df394db6afccfba763d010aa96b75fede166
6
+ metadata.gz: a726b52ecddba1503a2246192f95426b49c89e1c2c890052920e61248249266a5f4c74beb4e21e204c703568a835cfcc7a35e704c8c4a7036e35ffb83f3d2657
7
+ data.tar.gz: 498b8fd4f7865eacd2078b150e1338110ab5f6e16b28a92ff82efa62466d0f5dd1c1cc3346e5ab3f80517e6c88b50546c1d109ceeda8331c9451148e0f27e27d
@@ -3,12 +3,18 @@ module Bashly
3
3
  class Validate < Base
4
4
  help "Scan the configuration file for errors"
5
5
 
6
- usage "bashly validate"
6
+ usage "bashly validate [--verbose]"
7
7
  usage "bashly validate (-h|--help)"
8
8
 
9
+ option "-v --verbose", "Show the bashly configuration file prior to validating. This is useful when using split config (import) since it will show the final compiled configuration."
10
+
9
11
  environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
10
12
 
11
13
  def run
14
+ if args['--verbose']
15
+ lp config
16
+ puts "---"
17
+ end
12
18
  validate_config
13
19
  show_deprecations
14
20
  deprecations = config_validator.deprecations
@@ -119,6 +119,7 @@ module Bashly
119
119
  assert_optional_string "#{key}.footer", value['footer']
120
120
  assert_optional_string "#{key}.group", value['group']
121
121
  assert_optional_string "#{key}.filename", value['filename']
122
+ assert_optional_string "#{key}.function", value['function']
122
123
 
123
124
  assert_boolean "#{key}.private", value['private']
124
125
  assert_boolean "#{key}.default", value['default']
@@ -142,6 +143,10 @@ module Bashly
142
143
  assert_uniq "#{key}.flags", value['flags'], 'short'
143
144
  assert_uniq "#{key}.args", value['args'], 'name'
144
145
 
146
+ if value['function']
147
+ assert value['function'].match(/^[a-z0-9_]+$/), "#{key}.function must contain lowercase alphanumeric characters and underscores only"
148
+ end
149
+
145
150
  if value['default']
146
151
  assert value['args'], "#{key}.default makes no sense without args"
147
152
  end
@@ -9,7 +9,7 @@ module Bashly
9
9
  alias args catch_all commands completions
10
10
  default dependencies environment_variables examples
11
11
  extensible expose filename filters flags
12
- footer group help name
12
+ footer function group help name
13
13
  private version
14
14
  short
15
15
  ]
@@ -168,7 +168,7 @@ module Bashly
168
168
 
169
169
  # Returns a unique name, suitable to be used in a bash function
170
170
  def function_name
171
- full_name.to_underscore
171
+ options['function'] || full_name.to_underscore
172
172
  end
173
173
 
174
174
  # Returns the name of the command, including its parent name (in case
@@ -1,18 +1,21 @@
1
1
  module Bashly
2
2
  class Settings
3
3
  class << self
4
- attr_writer :source_dir, :target_dir, :lib_dir, :strict, :tab_indent
4
+ include AssetHelper
5
+
6
+ attr_writer :compact_short_flags, :source_dir, :target_dir,
7
+ :lib_dir, :strict, :tab_indent
5
8
 
6
9
  def source_dir
7
- @source_dir ||= get :source_dir, 'src'
10
+ @source_dir ||= get :source_dir
8
11
  end
9
12
 
10
13
  def target_dir
11
- @target_dir ||= get :target_dir, '.'
14
+ @target_dir ||= get :target_dir
12
15
  end
13
16
 
14
17
  def lib_dir
15
- @lib_dir ||= get :lib_dir, 'lib'
18
+ @lib_dir ||= get :lib_dir
16
19
  end
17
20
 
18
21
  def strict
@@ -23,8 +26,12 @@ module Bashly
23
26
  @tab_indent ||= get :tab_indent
24
27
  end
25
28
 
29
+ def compact_short_flags
30
+ @compact_short_flags ||= get :compact_short_flags
31
+ end
32
+
26
33
  def env
27
- @env ||= get(:env, :development)&.to_sym
34
+ @env ||= get(:env)&.to_sym
28
35
  end
29
36
 
30
37
  def env=(value)
@@ -41,14 +48,33 @@ module Bashly
41
48
 
42
49
  private
43
50
 
44
- def get(key, default = nil)
45
- ENV["BASHLY_#{key.upcase}"] || user_settings[key.to_s] || default
51
+ def get(key)
52
+ case env_value key
53
+ when nil then config[key.to_s]
54
+ when "0", "false", "no" then false
55
+ when "1", "true", "yes" then true
56
+ else env_value key
57
+ end
58
+ end
59
+
60
+ def env_value(key)
61
+ ENV["BASHLY_#{key.upcase}"]
62
+ end
63
+
64
+ def config
65
+ @config ||= defsult_settings.merge user_settings
46
66
  end
47
67
 
48
68
  def user_settings
49
- @user_settings ||= begin
50
- File.exist?('settings.yml') ? Config.new('settings.yml') : {}
51
- end
69
+ @user_settings ||= File.exist?('settings.yml') ? Config.new('settings.yml') : {}
70
+ end
71
+
72
+ def defsult_settings
73
+ @defsult_settings ||= Config.new(default_settings_path)
74
+ end
75
+
76
+ def default_settings_path
77
+ asset "templates/settings.yml"
52
78
  end
53
79
 
54
80
  end
@@ -1,6 +1,10 @@
1
1
  # All settings are optional (with their default values provided below), and
2
2
  # can also be set with an environment variable with the same name, capitalized
3
3
  # and prefixed by `BASHLY_` - for example: BASHLY_SOURCE_DIR
4
+ #
5
+ # When setting environment variables, you can use:
6
+ # - "0", "false" or "no" to represent false
7
+ # - "1", "true" or "yes" to represent true
4
8
 
5
9
  # The path containing the bashly configuration and source files
6
10
  source_dir: src
@@ -18,6 +22,10 @@ strict: false
18
22
  # (every 2 leading spaces will be converted to a tab character)
19
23
  tab_indent: false
20
24
 
25
+ # When true, the generated script will consider any argument in the form of
26
+ # `-abc` as if it is `-a -b -c`.
27
+ compact_short_flags: true
28
+
21
29
  # Set to 'production' or 'development':
22
30
  # - production generate a smaller script, without file markers
23
31
  # - development generate with file markers
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = "0.8.7"
2
+ VERSION = "0.8.9"
3
3
  end
@@ -11,11 +11,15 @@
11
11
  > elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
12
12
  > input+=("${BASH_REMATCH[1]}")
13
13
  > input+=("${BASH_REMATCH[2]}")
14
+
15
+ if Settings.compact_short_flags
14
16
  > elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
15
17
  > flags="${BASH_REMATCH[1]}"
16
18
  > for (( i=0 ; i < ${#flags} ; i++ )); do
17
19
  > input+=("-${flags:i:1}")
18
20
  > done
21
+ end
22
+
19
23
  > else
20
24
  > input+=("$arg")
21
25
  > 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: 0.8.7
4
+ version: 0.8.9
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: 2022-09-30 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: completely
@@ -53,21 +53,21 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.7'
55
55
  - !ruby/object:Gem::Dependency
56
- name: mister_bin
56
+ name: filewatcher
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.7'
61
+ version: '2.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.7'
68
+ version: '2.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: requires
70
+ name: lp
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
@@ -81,19 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.2'
83
83
  - !ruby/object:Gem::Dependency
84
- name: filewatcher
84
+ name: mister_bin
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.0'
89
+ version: '0.7'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.0'
96
+ version: '0.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: requires
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.2'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.2'
97
111
  description: Generate bash command line tools using YAML configuration
98
112
  email: db@dannyben.com
99
113
  executables: