bashly 1.3.4 → 1.3.5

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: fc29835d6181be972a508c311ad9554e9f57a8ad705804690ed4cb6aa98c6ab7
4
- data.tar.gz: 7f052f8027e16e8b3fcc684349aa784342c734e7e6381d0ff0032ec0b2a3da2c
3
+ metadata.gz: 429df4c59ef5a1dc0f1f9e332ab0b32b702fe5b83124c5ab04d784ef7d82bbc2
4
+ data.tar.gz: fdef11f71141111dea60129f9a9b855c669129010f5ec6e046fc0cdfafd9907f
5
5
  SHA512:
6
- metadata.gz: c019868212b40635d602a9e9c2f5bee24bb6cc5b6b78e748a37cb912cff799f932bbb365178f6b74354e8012d54e4e61bb86e47b01793fd340a5fe8a35f17eb2
7
- data.tar.gz: 7b4fd782e6e1e3a180a10c947581d9252db38da47a652afc3687d651ebf0eb0aa4a35d6ec0827ff6083d0f6cb935cd9aab9deb90bd2c1bbe411bc11493fd2cf0
6
+ metadata.gz: 17dcbf38797ebdd77898a53e09271cf7e0522c53af2f223910edc205f02d6ccd254eb4bcd11307f76656f14edaef253472efe0a9f699b9490f2ed3ef90746c85
7
+ data.tar.gz: 347ec4aebc9be7dcbcaef970db0465edf422b828361d3a37cfaa09337c372a1940a611b24a190af81dbb9857feeb8acc9c2d5662a39eac54df1f4504129c3424
@@ -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)
@@ -33,7 +33,7 @@ class String
33
33
  tr(' ', '/').downcase
34
34
  end
35
35
 
36
- def wrap(length = 80)
36
+ def wrap(length)
37
37
  strip!
38
38
  split("\n").collect! do |line|
39
39
  if line.length > length
@@ -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`
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.3.4'
2
+ VERSION = '1.3.5'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  = view_marker
2
2
 
3
3
  > printf " %s\n" "{{ label.color(:arg) }}"
4
- > printf "{{ help.wrap(76).indent(4).sanitize_for_print }}\n"
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.wrap(78).indent(2).sanitize_for_print }}\n" >&2
6
+ > printf "{{ user_string example, indent: 2 }}\n" >&2
7
7
  end
8
8
  end
@@ -6,8 +6,8 @@
6
6
 
7
7
  if root_command?
8
8
  >
9
- = render(:variables).indent(2)
10
9
  = render(:environment_variables_default).indent 2
10
+ = render(:variables).indent(2)
11
11
  end
12
12
 
13
13
  if user_file_exist?('initialize')
@@ -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.wrap(78).indent(2).sanitize_for_print }}\n\n"
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"
@@ -12,7 +12,7 @@ end
12
12
  if catch_all.help
13
13
  >
14
14
  > echo " {{ catch_all.label }}"
15
- > printf "{{ catch_all.help.wrap(76).indent(4).sanitize_for_print }}\n"
15
+ > printf "{{ user_string catch_all.help, indent: 4 }}\n"
16
16
  > echo
17
17
  end
18
18
 
@@ -3,7 +3,7 @@
3
3
  > printf "%s\n" "{{ strings[:examples].color(:caption) }}"
4
4
 
5
5
  examples.each do |example|
6
- > printf "{{ example.wrap(78).indent(2).sanitize_for_print }}\n"
6
+ > printf "{{ user_string example, indent: 2 }}\n"
7
7
  end
8
8
 
9
9
  > echo
@@ -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.wrap(76).indent(4).sanitize_for_print }}\n"
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.wrap(76).indent(4).sanitize_for_print }}\n"
4
+ > printf "{{ user_string help, indent: 4 }}\n"
5
5
 
6
6
  if allowed
7
7
  > printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}"
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
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
@@ -359,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
359
  - !ruby/object:Gem::Version
360
360
  version: '0'
361
361
  requirements: []
362
- rubygems_version: 3.6.9
362
+ rubygems_version: 4.0.0
363
363
  specification_version: 4
364
364
  summary: Bash Command Line Tool Generator
365
365
  test_files: []