bashly 1.3.4 → 1.3.6
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/commands/generate.rb +1 -3
- data/lib/bashly/commands/render.rb +1 -2
- data/lib/bashly/concerns/renderable.rb +7 -0
- data/lib/bashly/extensions/string.rb +1 -1
- data/lib/bashly/libraries/settings/settings.yml +3 -0
- data/lib/bashly/settings.rb +6 -1
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/argument/usage.gtx +1 -1
- data/lib/bashly/views/command/examples_on_error.gtx +1 -1
- data/lib/bashly/views/command/initialize.gtx +1 -1
- data/lib/bashly/views/command/usage.gtx +1 -1
- data/lib/bashly/views/command/usage_args.gtx +1 -1
- data/lib/bashly/views/command/usage_examples.gtx +1 -1
- data/lib/bashly/views/environment_variable/usage.gtx +1 -1
- data/lib/bashly/views/flag/usage.gtx +1 -1
- data/lib/bashly/watch.rb +57 -0
- data/lib/bashly.rb +1 -1
- metadata +15 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c216518e1752d66966dfa1b8efad9a24afb5d55119a350ac9ad460abea748be0
|
|
4
|
+
data.tar.gz: 8626f99cfc41d424363969bbe46474fc86f8998f44c17d8196c03044281fbf6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b49310fec1d05dcf12504a8be34493d4e6d8af7ef9b2e35ea57da6424ca0820ee6abb7145ea54835ac31778db0ff89e6c6999050133f5851545ac67dc7f5b6c
|
|
7
|
+
data.tar.gz: 0b443ed8497671ff9faf2c720961d3344a5bbfb670096c9a74388cb54541f782b4316a198e4b2dfc7ed17b45a83991df2894ce05f3d76f943f694a63aa090bb2
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'filewatcher'
|
|
2
|
-
|
|
3
1
|
module Bashly
|
|
4
2
|
module Commands
|
|
5
3
|
class Generate < Base
|
|
@@ -41,7 +39,7 @@ module Bashly
|
|
|
41
39
|
def watch
|
|
42
40
|
quiet_say "g`watching` #{Settings.source_dir}\n"
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
Watch.new(Settings.source_dir).on_change do
|
|
45
43
|
reset
|
|
46
44
|
generate
|
|
47
45
|
rescue Bashly::ConfigurationError => e
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require 'filewatcher'
|
|
2
1
|
require 'tty-markdown'
|
|
3
2
|
|
|
4
3
|
module Bashly
|
|
@@ -75,7 +74,7 @@ module Bashly
|
|
|
75
74
|
def watch
|
|
76
75
|
say "g`watching`\n"
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
Watch.new(*watchables).on_change do
|
|
79
78
|
render
|
|
80
79
|
say "g`waiting`\n"
|
|
81
80
|
end
|
|
@@ -51,6 +51,13 @@ module Bashly
|
|
|
51
51
|
File.exist? user_file_path(file)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
# Returns a wrapped, indented and sanitized string
|
|
55
|
+
# Designed to place help and example messages inside bash's 'printf'
|
|
56
|
+
def user_string(text, indent: 0)
|
|
57
|
+
wrap = Settings.word_wrap - indent
|
|
58
|
+
text.wrap(wrap).indent(indent).sanitize_for_print
|
|
59
|
+
end
|
|
60
|
+
|
|
54
61
|
private
|
|
55
62
|
|
|
56
63
|
def view_path(view)
|
|
@@ -84,6 +84,9 @@ strict: false
|
|
|
84
84
|
# (every 2 leading spaces will be converted to a tab character)
|
|
85
85
|
tab_indent: false
|
|
86
86
|
|
|
87
|
+
# Set the character width used to wrap help and example messages
|
|
88
|
+
word_wrap: 80
|
|
89
|
+
|
|
87
90
|
# Choose a post-processor for the generated script:
|
|
88
91
|
# formatter: internal # Use Bashly’s built-in formatter (removes extra newlines)
|
|
89
92
|
# formatter: external # Run the external command `shfmt --case-indent --indent 2`
|
data/lib/bashly/settings.rb
CHANGED
|
@@ -27,7 +27,8 @@ module Bashly
|
|
|
27
27
|
:tab_indent,
|
|
28
28
|
:target_dir,
|
|
29
29
|
:usage_colors,
|
|
30
|
-
:var_aliases
|
|
30
|
+
:var_aliases,
|
|
31
|
+
:word_wrap
|
|
31
32
|
)
|
|
32
33
|
|
|
33
34
|
def commands_dir
|
|
@@ -173,6 +174,10 @@ module Bashly
|
|
|
173
174
|
@var_aliases ||= get :var_aliases
|
|
174
175
|
end
|
|
175
176
|
|
|
177
|
+
def word_wrap
|
|
178
|
+
@word_wrap ||= get :word_wrap
|
|
179
|
+
end
|
|
180
|
+
|
|
176
181
|
private
|
|
177
182
|
|
|
178
183
|
def get(key)
|
data/lib/bashly/version.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
= view_marker
|
|
2
2
|
|
|
3
3
|
> printf " %s\n" "{{ label.color(:arg) }}"
|
|
4
|
-
> printf "{{ help
|
|
4
|
+
> printf "{{ user_string help, indent: 4 }}\n"
|
|
5
5
|
|
|
6
6
|
if allowed
|
|
7
7
|
> printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}"
|
|
@@ -3,6 +3,6 @@ if Settings.show_examples_on_error && examples
|
|
|
3
3
|
|
|
4
4
|
> printf "{{ strings[:examples_caption_on_error] }}\n" >&2
|
|
5
5
|
examples.each do |example|
|
|
6
|
-
> printf "{{ example
|
|
6
|
+
> printf "{{ user_string example, indent: 2 }}\n" >&2
|
|
7
7
|
end
|
|
8
8
|
end
|
|
@@ -9,7 +9,7 @@ else
|
|
|
9
9
|
= help_header_override.indent 4
|
|
10
10
|
else
|
|
11
11
|
> printf "{{ full_name }}\n\n"
|
|
12
|
-
> printf "{{ help
|
|
12
|
+
> printf "{{ user_string help, indent: 2 }}\n\n"
|
|
13
13
|
end
|
|
14
14
|
> else
|
|
15
15
|
> printf "{{ caption_string.sanitize_for_print }}\n\n"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
= view_marker
|
|
2
2
|
|
|
3
3
|
> printf " %s\n" "{{ usage_string(extended: true).color(:environment_variable) }}"
|
|
4
|
-
> printf "{{ help
|
|
4
|
+
> printf "{{ user_string help, indent: 4 }}\n"
|
|
5
5
|
|
|
6
6
|
if allowed
|
|
7
7
|
> printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
= view_marker
|
|
2
2
|
|
|
3
3
|
> printf " %s\n" "{{ usage_string(extended: true).color(:flag) }}"
|
|
4
|
-
> printf "{{ help
|
|
4
|
+
> printf "{{ user_string help, indent: 4 }}\n"
|
|
5
5
|
|
|
6
6
|
if allowed
|
|
7
7
|
> printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}"
|
data/lib/bashly/watch.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'listen'
|
|
2
|
+
|
|
3
|
+
module Bashly
|
|
4
|
+
# File system watcher - an ergonomic wrapper around the Listen gem
|
|
5
|
+
class Watch
|
|
6
|
+
attr_reader :dirs, :options
|
|
7
|
+
|
|
8
|
+
DEFAULT_OPTIONS = {
|
|
9
|
+
force_polling: true,
|
|
10
|
+
latency: 1.0,
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
def initialize(*dirs, **options)
|
|
14
|
+
@options = DEFAULT_OPTIONS.merge(options).freeze
|
|
15
|
+
@dirs = dirs.empty? ? ['.'] : dirs
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def on_change(&)
|
|
19
|
+
start(&)
|
|
20
|
+
wait
|
|
21
|
+
ensure
|
|
22
|
+
stop
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def build_listener
|
|
28
|
+
listen.to(*dirs, **options) do |modified, added, removed|
|
|
29
|
+
yield changes(modified, added, removed)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def start(&block)
|
|
34
|
+
raise ArgumentError, 'block required' unless block
|
|
35
|
+
|
|
36
|
+
@listener = build_listener(&block)
|
|
37
|
+
@listener.start
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def stop
|
|
41
|
+
@listener&.stop
|
|
42
|
+
@listener = nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def changes(modified, added, removed)
|
|
46
|
+
{ modified:, added:, removed: }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def wait
|
|
50
|
+
sleep
|
|
51
|
+
rescue ::Interrupt => e
|
|
52
|
+
raise Bashly::Interrupt, cause: e
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def listen = Listen
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/bashly.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Bashly
|
|
|
12
12
|
|
|
13
13
|
autoloads 'bashly', %i[
|
|
14
14
|
CLI Config ConfigValidator Library LibrarySource LibrarySourceConfig
|
|
15
|
-
MessageStrings RenderContext RenderSource Settings VERSION
|
|
15
|
+
MessageStrings RenderContext RenderSource Settings VERSION Watch
|
|
16
16
|
]
|
|
17
17
|
|
|
18
18
|
autoloads 'bashly/concerns', %i[
|
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: 1.3.
|
|
4
|
+
version: 1.3.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Danny Ben Shitrit
|
|
@@ -38,33 +38,33 @@ dependencies:
|
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: 0.7.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
|
-
name:
|
|
41
|
+
name: gtx
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version:
|
|
46
|
+
version: 0.1.1
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 0.1.1
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
|
-
name:
|
|
55
|
+
name: listen
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version:
|
|
60
|
+
version: '3.9'
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version:
|
|
67
|
+
version: '3.9'
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: lp
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,14 +85,14 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.
|
|
88
|
+
version: 0.9.0
|
|
89
89
|
type: :runtime
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.
|
|
95
|
+
version: 0.9.0
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: requires
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -125,42 +125,16 @@ dependencies:
|
|
|
125
125
|
name: logger
|
|
126
126
|
requirement: !ruby/object:Gem::Requirement
|
|
127
127
|
requirements:
|
|
128
|
-
- - "
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '1'
|
|
131
|
-
- - "<"
|
|
132
|
-
- !ruby/object:Gem::Version
|
|
133
|
-
version: '3'
|
|
134
|
-
type: :runtime
|
|
135
|
-
prerelease: false
|
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
137
|
-
requirements:
|
|
138
|
-
- - ">="
|
|
139
|
-
- !ruby/object:Gem::Version
|
|
140
|
-
version: '1'
|
|
141
|
-
- - "<"
|
|
142
|
-
- !ruby/object:Gem::Version
|
|
143
|
-
version: '3'
|
|
144
|
-
- !ruby/object:Gem::Dependency
|
|
145
|
-
name: ostruct
|
|
146
|
-
requirement: !ruby/object:Gem::Requirement
|
|
147
|
-
requirements:
|
|
148
|
-
- - ">="
|
|
149
|
-
- !ruby/object:Gem::Version
|
|
150
|
-
version: '0'
|
|
151
|
-
- - "<"
|
|
128
|
+
- - "~>"
|
|
152
129
|
- !ruby/object:Gem::Version
|
|
153
|
-
version: '
|
|
130
|
+
version: '1.7'
|
|
154
131
|
type: :runtime
|
|
155
132
|
prerelease: false
|
|
156
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
157
134
|
requirements:
|
|
158
|
-
- - "
|
|
159
|
-
- !ruby/object:Gem::Version
|
|
160
|
-
version: '0'
|
|
161
|
-
- - "<"
|
|
135
|
+
- - "~>"
|
|
162
136
|
- !ruby/object:Gem::Version
|
|
163
|
-
version: '
|
|
137
|
+
version: '1.7'
|
|
164
138
|
description: Generate bash command line tools using YAML configuration
|
|
165
139
|
email: db@dannyben.com
|
|
166
140
|
executables:
|
|
@@ -336,6 +310,7 @@ files:
|
|
|
336
310
|
- lib/bashly/views/wrapper/bash3_bouncer.gtx
|
|
337
311
|
- lib/bashly/views/wrapper/header.gtx
|
|
338
312
|
- lib/bashly/views/wrapper/wrapper.gtx
|
|
313
|
+
- lib/bashly/watch.rb
|
|
339
314
|
homepage: https://github.com/bashly-framework/bashly
|
|
340
315
|
licenses:
|
|
341
316
|
- MIT
|
|
@@ -359,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
359
334
|
- !ruby/object:Gem::Version
|
|
360
335
|
version: '0'
|
|
361
336
|
requirements: []
|
|
362
|
-
rubygems_version:
|
|
337
|
+
rubygems_version: 4.0.3
|
|
363
338
|
specification_version: 4
|
|
364
339
|
summary: Bash Command Line Tool Generator
|
|
365
340
|
test_files: []
|