bashly 2.0.0.rc1 → 2.0.0.rc2
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 +4 -4
- data/lib/bashly/concerns/settings_completions.rb +37 -0
- data/lib/bashly/config_validator.rb +3 -1
- data/lib/bashly/libraries/settings/settings.yml +3 -5
- data/lib/bashly/script/argument.rb +5 -0
- data/lib/bashly/settings.rb +2 -28
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/completion_argument_candidates.gtx +4 -3
- data/lib/bashly/views/command/master_script.gtx +6 -4
- data/lib/bashly/views/command/start.gtx +9 -9
- data/lib/bashly/watch.rb +22 -50
- data/lib/bashly.rb +1 -1
- metadata +18 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65ab4d9e6acb0f638497f14958c9bebc78219cbb1c677d75b5f9f98506301e4c
|
|
4
|
+
data.tar.gz: fadcbfe0d4dcc48d6081d50f2a76bc57730ebd6e44b7c9a232350e7d072f2d3c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a775101849773351872c8f84ce312ec9d5ebc7a460bfed5858de9edf41d524c319e3dd48c424d3be30379ef79ee3e1d1e4bc4efd4b2b5164f641a3c3e47ee03e
|
|
7
|
+
data.tar.gz: 58ebb9d697a27856f7383d0ad69a5de4c06b21766347c769f241c1dcd947f2703bb932abf0733624e9a3fc7f475891076136d0038734cbe0b346a90b89d6192c
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Bashly
|
|
2
|
+
module SettingsCompletions
|
|
3
|
+
COMPLETION_SHELLS = %w[bash zsh].freeze
|
|
4
|
+
|
|
5
|
+
def completions
|
|
6
|
+
@completions ||= get :completions
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def completions?
|
|
10
|
+
completions == 'minimal' || completion_shells.any?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def completion_shells
|
|
14
|
+
case completions
|
|
15
|
+
when nil, false, 'minimal' then []
|
|
16
|
+
when 'full' then COMPLETION_SHELLS
|
|
17
|
+
when String then validate_completion_shells completions
|
|
18
|
+
else invalid_completions
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def validate_completion_shells(value)
|
|
25
|
+
shells = value.split(',', -1).map(&:strip)
|
|
26
|
+
valid = shells.any? && (shells - COMPLETION_SHELLS).empty?
|
|
27
|
+
return shells if valid && shells.uniq == shells
|
|
28
|
+
|
|
29
|
+
invalid_completions
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def invalid_completions
|
|
33
|
+
raise ConfigurationError,
|
|
34
|
+
"completions must be false, minimal, full, or a comma-separated list of: #{COMPLETION_SHELLS.join ', '}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -2,6 +2,8 @@ module Bashly
|
|
|
2
2
|
class ConfigValidator
|
|
3
3
|
include ValidationHelpers
|
|
4
4
|
|
|
5
|
+
COMPLETION_OPTIONS = %w[files directories no-space].freeze
|
|
6
|
+
|
|
5
7
|
attr_reader :data
|
|
6
8
|
|
|
7
9
|
def initialize(data)
|
|
@@ -97,7 +99,7 @@ module Bashly
|
|
|
97
99
|
assert_array "#{key}.options", value['options'], of: :string
|
|
98
100
|
|
|
99
101
|
Array(value['options']).each do |option|
|
|
100
|
-
assert
|
|
102
|
+
assert COMPLETION_OPTIONS.include?(option),
|
|
101
103
|
"#{key}.options contains an unknown option: #{option}"
|
|
102
104
|
end
|
|
103
105
|
end
|
|
@@ -177,11 +177,8 @@ completions: ~
|
|
|
177
177
|
# DEVELOPER OPTIONS
|
|
178
178
|
#-------------------------------------------------------------------------------
|
|
179
179
|
|
|
180
|
-
#
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
# File change detection latency (seconds)
|
|
184
|
-
watch_latency: 1.0
|
|
180
|
+
# File change detection polling interval (seconds)
|
|
181
|
+
watch_latency: 2.0
|
|
185
182
|
|
|
186
183
|
|
|
187
184
|
#-------------------------------------------------------------------------------
|
|
@@ -200,5 +197,6 @@ var_aliases:
|
|
|
200
197
|
|
|
201
198
|
# Choose different names for some of the internal functions.
|
|
202
199
|
function_names:
|
|
200
|
+
start: ~
|
|
203
201
|
run: ~
|
|
204
202
|
initialize: ~
|
|
@@ -35,6 +35,11 @@ module Bashly
|
|
|
35
35
|
completions&.fetch('options', []) || []
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
def completion?
|
|
39
|
+
allowed&.any? || completion_static.any? ||
|
|
40
|
+
completion_dynamic.any? || completion_options.any?
|
|
41
|
+
end
|
|
42
|
+
|
|
38
43
|
def label
|
|
39
44
|
repeatable ? "#{name.upcase}..." : name.upcase
|
|
40
45
|
end
|
data/lib/bashly/settings.rb
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
module Bashly
|
|
2
2
|
class Settings
|
|
3
|
-
COMPLETION_SHELLS =
|
|
3
|
+
COMPLETION_SHELLS = SettingsCompletions::COMPLETION_SHELLS
|
|
4
4
|
|
|
5
5
|
class << self
|
|
6
6
|
include AssetHelper
|
|
7
|
+
include SettingsCompletions
|
|
7
8
|
|
|
8
9
|
attr_writer(
|
|
9
10
|
:argfile_var,
|
|
@@ -32,7 +33,6 @@ module Bashly
|
|
|
32
33
|
:target_dir,
|
|
33
34
|
:usage_colors,
|
|
34
35
|
:var_aliases,
|
|
35
|
-
:watch_evented,
|
|
36
36
|
:watch_latency,
|
|
37
37
|
:word_wrap
|
|
38
38
|
)
|
|
@@ -53,28 +53,6 @@ module Bashly
|
|
|
53
53
|
@compact_short_flags ||= get :compact_short_flags
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def completions
|
|
57
|
-
@completions ||= get :completions
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def completions?
|
|
61
|
-
completions == 'minimal' || completion_shells.any?
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def completion_shells
|
|
65
|
-
value = completions
|
|
66
|
-
return [] if value.nil? || value == false || value == 'minimal'
|
|
67
|
-
return COMPLETION_SHELLS if value == 'full'
|
|
68
|
-
|
|
69
|
-
shells = value.split(',', -1).map(&:strip) if value.is_a? String
|
|
70
|
-
valid = shells&.any? && shells.all? { |shell| COMPLETION_SHELLS.include? shell }
|
|
71
|
-
unique = shells&.uniq == shells
|
|
72
|
-
return shells if valid && unique
|
|
73
|
-
|
|
74
|
-
raise ConfigurationError,
|
|
75
|
-
"completions must be false, minimal, full, or a comma-separated list of: #{COMPLETION_SHELLS.join ', '}"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
56
|
def conjoined_flag_args
|
|
79
57
|
@conjoined_flag_args ||= get :conjoined_flag_args
|
|
80
58
|
end
|
|
@@ -206,10 +184,6 @@ module Bashly
|
|
|
206
184
|
@var_aliases ||= get :var_aliases
|
|
207
185
|
end
|
|
208
186
|
|
|
209
|
-
def watch_evented
|
|
210
|
-
@watch_evented ||= get :watch_evented
|
|
211
|
-
end
|
|
212
|
-
|
|
213
187
|
def watch_latency
|
|
214
188
|
@watch_latency ||= get :watch_latency
|
|
215
189
|
end
|
data/lib/bashly/version.rb
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
completion_args = args.each_with_index.select { |arg, _index| arg.completion? }
|
|
2
|
+
if completion_args.any?
|
|
2
3
|
> if [[ $completion_current != -* ]]; then
|
|
3
4
|
> case "$completion_arg_index" in
|
|
4
|
-
|
|
5
|
+
completion_args.each do |arg, index|
|
|
5
6
|
> {{ index }})
|
|
6
|
-
= arg.render(:completion).indent 6
|
|
7
|
+
= arg.render(:completion).strip.indent 6
|
|
7
8
|
> ;;
|
|
8
9
|
end
|
|
9
10
|
> esac
|
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
= render :initialize
|
|
14
14
|
= render :run
|
|
15
15
|
|
|
16
|
-
>
|
|
16
|
+
>
|
|
17
|
+
= render :start
|
|
18
|
+
>
|
|
17
19
|
if Settings.enabled? :sourcing
|
|
18
20
|
> if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
19
|
-
|
|
21
|
+
> {{ Settings.function_name :start }} "$@"
|
|
20
22
|
> fi
|
|
21
23
|
else
|
|
22
|
-
|
|
24
|
+
> {{ Settings.function_name :start }} "$@"
|
|
23
25
|
end
|
|
24
|
-
>
|
|
26
|
+
>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
= view_marker
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> {{ Settings.function_name :start }}() {
|
|
4
4
|
if Settings.completions?
|
|
5
|
-
>
|
|
6
|
-
>
|
|
7
|
-
>
|
|
5
|
+
> if [[ ${1:-} == "__complete" ]]; then
|
|
6
|
+
> completion_run "${@:2}"
|
|
7
|
+
> return
|
|
8
|
+
> fi
|
|
9
|
+
>
|
|
10
|
+
end
|
|
11
|
+
> command_line_args=("$@")
|
|
8
12
|
> {{ Settings.function_name :initialize }}
|
|
9
13
|
> {{ Settings.function_name :run }} "${command_line_args[@]}"
|
|
10
|
-
>
|
|
11
|
-
else
|
|
12
|
-
> {{ Settings.function_name :initialize }}
|
|
13
|
-
> {{ Settings.function_name :run }} "${command_line_args[@]}"
|
|
14
|
-
end
|
|
14
|
+
> }
|
data/lib/bashly/watch.rb
CHANGED
|
@@ -1,68 +1,40 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'watchly'
|
|
2
2
|
|
|
3
3
|
module Bashly
|
|
4
|
-
# File system watcher - an ergonomic wrapper around the
|
|
4
|
+
# File system watcher - an ergonomic wrapper around the Watchly gem
|
|
5
5
|
class Watch
|
|
6
|
-
attr_reader :
|
|
6
|
+
attr_reader :interval, :targets
|
|
7
7
|
|
|
8
|
-
def initialize(*
|
|
9
|
-
@
|
|
10
|
-
@
|
|
8
|
+
def initialize(*targets, interval: nil)
|
|
9
|
+
@targets = targets.empty? ? ['.'] : targets
|
|
10
|
+
@interval = interval || default_interval
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def on_change
|
|
14
|
-
|
|
15
|
-
wait
|
|
16
|
-
ensure
|
|
17
|
-
stop
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
13
|
+
def on_change
|
|
14
|
+
raise ArgumentError, 'block required' unless block_given?
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
watcher.on_change do |changes|
|
|
17
|
+
yield normalize(changes)
|
|
18
|
+
end
|
|
19
|
+
rescue ::Interrupt => e
|
|
20
|
+
raise Bashly::Interrupt, cause: e
|
|
27
21
|
end
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
!Settings.watch_evented
|
|
31
|
-
end
|
|
23
|
+
private
|
|
32
24
|
|
|
33
|
-
def
|
|
25
|
+
def default_interval
|
|
34
26
|
value = Settings.watch_latency.to_f
|
|
35
27
|
value.positive? ? value : 0.1
|
|
36
28
|
end
|
|
37
29
|
|
|
38
|
-
def
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def stop
|
|
46
|
-
@listener&.stop
|
|
47
|
-
@listener = nil
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def wait
|
|
51
|
-
sleep
|
|
52
|
-
rescue ::Interrupt => e
|
|
53
|
-
raise Bashly::Interrupt, cause: e
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def build_listener
|
|
57
|
-
listen.to(*dirs, **options) do |modified, added, removed|
|
|
58
|
-
yield changes(modified, added, removed)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def changes(modified, added, removed)
|
|
63
|
-
{ modified:, added:, removed: }
|
|
30
|
+
def normalize(changes)
|
|
31
|
+
{
|
|
32
|
+
modified: changes.modified,
|
|
33
|
+
added: changes.added,
|
|
34
|
+
removed: changes.removed,
|
|
35
|
+
}
|
|
64
36
|
end
|
|
65
37
|
|
|
66
|
-
def
|
|
38
|
+
def watcher = @watcher ||= Watchly::Watcher.new(*targets, interval:)
|
|
67
39
|
end
|
|
68
40
|
end
|
data/lib/bashly.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bashly
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.
|
|
4
|
+
version: 2.0.0.rc2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Danny Ben Shitrit
|
|
@@ -37,20 +37,6 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: 0.1.1
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: listen
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '3.9'
|
|
47
|
-
type: :runtime
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '3.9'
|
|
54
40
|
- !ruby/object:Gem::Dependency
|
|
55
41
|
name: lp
|
|
56
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -107,6 +93,20 @@ dependencies:
|
|
|
107
93
|
- - "~>"
|
|
108
94
|
- !ruby/object:Gem::Version
|
|
109
95
|
version: 0.7.2
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: watchly
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: 0.2.0
|
|
103
|
+
type: :runtime
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 0.2.0
|
|
110
110
|
description: Generate bash command line tools using YAML configuration
|
|
111
111
|
email: db@dannyben.com
|
|
112
112
|
executables:
|
|
@@ -135,6 +135,7 @@ files:
|
|
|
135
135
|
- lib/bashly/concerns/asset_helper.rb
|
|
136
136
|
- lib/bashly/concerns/indentation_helper.rb
|
|
137
137
|
- lib/bashly/concerns/renderable.rb
|
|
138
|
+
- lib/bashly/concerns/settings_completions.rb
|
|
138
139
|
- lib/bashly/concerns/validation_helpers.rb
|
|
139
140
|
- lib/bashly/config.rb
|
|
140
141
|
- lib/bashly/config_validator.rb
|
|
@@ -299,7 +300,7 @@ files:
|
|
|
299
300
|
- lib/bashly/views/wrapper/header.gtx
|
|
300
301
|
- lib/bashly/views/wrapper/wrapper.gtx
|
|
301
302
|
- lib/bashly/watch.rb
|
|
302
|
-
homepage: https://
|
|
303
|
+
homepage: https://bashly.dev
|
|
303
304
|
licenses:
|
|
304
305
|
- MIT
|
|
305
306
|
metadata:
|
|
@@ -324,5 +325,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
324
325
|
requirements: []
|
|
325
326
|
rubygems_version: 4.0.17
|
|
326
327
|
specification_version: 4
|
|
327
|
-
summary: Bash
|
|
328
|
+
summary: Bash command-line framework and CLI generator
|
|
328
329
|
test_files: []
|