bashly 1.3.7 → 1.4.0.rc1

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.
@@ -7,11 +7,6 @@ module Bashly
7
7
  deep_commands(include_self: true).any? { |x| x.catch_all.enabled? }
8
8
  end
9
9
 
10
- # Returns true if the command or any of its descendants has `argfile`
11
- def argfile_used_anywhere?
12
- deep_commands(include_self: true).any?(&:argfile)
13
- end
14
-
15
10
  # Returns a full list of the Command names and aliases combined
16
11
  def command_aliases
17
12
  commands.map(&:aliases).flatten
@@ -4,6 +4,7 @@ module Bashly
4
4
  include AssetHelper
5
5
 
6
6
  attr_writer(
7
+ :argfile_var,
7
8
  :commands_dir,
8
9
  :compact_short_flags,
9
10
  :conjoined_flag_args,
@@ -37,6 +38,10 @@ module Bashly
37
38
  @all_lib_dirs = [full_lib_dir] + extra_lib_dirs
38
39
  end
39
40
 
41
+ def argfile_var
42
+ @argfile_var ||= get :argfile_var
43
+ end
44
+
40
45
  def commands_dir
41
46
  @commands_dir ||= get :commands_dir
42
47
  end
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.3.7'
2
+ VERSION = '1.4.0.rc1'
3
3
  end
@@ -1,5 +1,29 @@
1
1
  = view_marker
2
2
 
3
- > load_command_argfile "{{ argfile }}" "$@"
4
- > set -- "${argfile_input[@]}"
3
+ > local argfile argfile_line argfile_key argfile_value env_argfile env_argfile_var
4
+ > argfile="{{ argfile }}"
5
+ > env_argfile_var="{{ Settings.argfile_var }}"
6
+ > env_argfile="${!env_argfile_var:-}"
7
+ >
8
+ > case "${env_argfile,,}" in
9
+ > 0 | off | no | false)
10
+ > argfile=''
11
+ > ;;
12
+ > esac
13
+ >
14
+ > [[ -n "$env_argfile" ]] && argfile="$env_argfile"
15
+ > if [[ -f "$argfile" ]]; then
16
+ > while IFS= read -r argfile_line || [[ -n "$argfile_line" ]]; do
17
+ > [[ "$argfile_line" =~ ^[[:space:]]*(-{1,2}[^[:space:]]+)([[:space:]]+(.+))?[[:space:]]*$ ]] || continue
18
+ > argfile_key="${BASH_REMATCH[1]}"
19
+ > argfile_value="${BASH_REMATCH[3]:-}"
20
+ > argfile_value="${argfile_value#"${argfile_value%%[![:space:]]*}"}"
21
+ > argfile_value="${argfile_value%"${argfile_value##*[![:space:]]}"}"
22
+ > [[ "$argfile_value" =~ ^\"(.*)\"$ || "$argfile_value" =~ ^\'(.*)\'$ ]] && argfile_value="${BASH_REMATCH[1]}"
23
+ >
24
+ > case "$argfile_key" in
25
+ = flags.map { |flag| flag.render(:argfile_case) }.join.indent 6
26
+ > esac
27
+ > done <"$argfile"
28
+ > fi
5
29
  >
@@ -4,7 +4,6 @@
4
4
  = render :version_command
5
5
  = render :usage
6
6
  = render :normalize_input
7
- = render :argfile_helpers if argfile_used_anywhere?
8
7
  = render :inspect_args if Settings.enabled? :inspect_args
9
8
  = render :user_lib if user_lib.any?
10
9
  = render :command_functions
@@ -8,8 +8,8 @@ end
8
8
  > local key
9
9
  >
10
10
 
11
- = render(:argfile_filter).indent 2 if argfile
12
11
  = render(:fixed_flags_filter).indent 2
12
+ = render(:argfile_filter).indent 2 if argfile
13
13
  = render(:environment_variables_filter).indent 2
14
14
  = render(:dependencies_filter).indent 2
15
15
  = render(:command_filter).indent 2
@@ -0,0 +1,6 @@
1
+ = view_marker
2
+
3
+ > {{ aliases.join " | " }})
4
+ = render(arg ? :argfile_case_arg : :argfile_case_no_arg).indent 2
5
+ > ;;
6
+ >
@@ -0,0 +1,23 @@
1
+ = view_marker
2
+
3
+ > if [[ -n "$argfile_value" ]]; then
4
+
5
+ if repeatable
6
+ > escaped="$(printf '%q' "$argfile_value")"
7
+ > if [[ -z ${args['{{ name }}']+x} ]]; then
8
+ > args['{{ name }}']="$escaped"
9
+ if unique
10
+ > unique_lookup["{{ name }}:$escaped"]=1
11
+ > elif [[ -z "${unique_lookup["{{ name }}:$escaped"]:-}" ]]; then
12
+ > args['{{ name }}']="${args['{{ name }}']} $escaped"
13
+ > unique_lookup["{{ name }}:$escaped"]=1
14
+ else
15
+ > else
16
+ > args['{{ name }}']="${args['{{ name }}']} $escaped"
17
+ end
18
+ > fi
19
+ else
20
+ > [[ -n ${args['{{ name }}']+x} ]] || args['{{ name }}']="$argfile_value"
21
+ end
22
+
23
+ > fi
@@ -0,0 +1,7 @@
1
+ = view_marker
2
+
3
+ if repeatable
4
+ > ((args['{{ name }}'] += 1))
5
+ else
6
+ > [[ -n ${args['{{ name }}']+x} ]] || args['{{ name }}']=1
7
+ end
data/lib/bashly.rb CHANGED
@@ -6,8 +6,9 @@ module Bashly
6
6
  autoloads 'bashly/refinements', %i[ComposeRefinements]
7
7
 
8
8
  autoloads 'bashly', %i[
9
- CLI Config ConfigValidator Library LibrarySource LibrarySourceConfig
10
- MessageStrings RenderContext RenderSource Settings VERSION Watch
9
+ CLI CompletionBuilder Config ConfigValidator Library LibrarySource
10
+ LibrarySourceConfig MessageStrings RenderContext RenderSource Settings
11
+ VERSION Watch
11
12
  ]
12
13
 
13
14
  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.7
4
+ version: 1.4.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.7.0
32
+ version: 0.8.0.rc4
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.7.0
39
+ version: 0.8.0.rc4
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: gtx
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -156,6 +156,7 @@ files:
156
156
  - lib/bashly/commands/render.rb
157
157
  - lib/bashly/commands/shell.rb
158
158
  - lib/bashly/commands/validate.rb
159
+ - lib/bashly/completion_builder.rb
159
160
  - lib/bashly/completions/README.md
160
161
  - lib/bashly/completions/bashly-completions.bash
161
162
  - lib/bashly/completions/completely.yaml
@@ -247,7 +248,6 @@ files:
247
248
  - lib/bashly/views/argument/usage.gtx
248
249
  - lib/bashly/views/argument/validations.gtx
249
250
  - lib/bashly/views/command/argfile_filter.gtx
250
- - lib/bashly/views/command/argfile_helpers.gtx
251
251
  - lib/bashly/views/command/catch_all_filter.gtx
252
252
  - lib/bashly/views/command/command_fallback.gtx
253
253
  - lib/bashly/views/command/command_filter.gtx
@@ -299,6 +299,9 @@ files:
299
299
  - lib/bashly/views/dependency/filter.gtx
300
300
  - lib/bashly/views/environment_variable/usage.gtx
301
301
  - lib/bashly/views/environment_variable/validations.gtx
302
+ - lib/bashly/views/flag/argfile_case.gtx
303
+ - lib/bashly/views/flag/argfile_case_arg.gtx
304
+ - lib/bashly/views/flag/argfile_case_no_arg.gtx
302
305
  - lib/bashly/views/flag/case.gtx
303
306
  - lib/bashly/views/flag/case_arg.gtx
304
307
  - lib/bashly/views/flag/case_no_arg.gtx
@@ -334,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
337
  - !ruby/object:Gem::Version
335
338
  version: '0'
336
339
  requirements: []
337
- rubygems_version: 4.0.3
340
+ rubygems_version: 4.0.15
338
341
  specification_version: 4
339
342
  summary: Bash Command Line Tool Generator
340
343
  test_files: []
@@ -1,36 +0,0 @@
1
- = view_marker
2
-
3
- > load_command_argfile() {
4
- > local argfile_path line arg
5
- > argfile_path="$1"
6
- > shift
7
- > argfile_input=()
8
- >
9
- > if [[ ! -f "$argfile_path" ]]; then
10
- > argfile_input=("$@")
11
- > return
12
- > fi
13
- >
14
- > while IFS= read -r line || [[ -n "$line" ]]; do
15
- > line="${line#"${line%%[![:space:]]*}"}"
16
- > line="${line%"${line##*[![:space:]]}"}"
17
- >
18
- > [[ -z "$line" || "${line:0:1}" == "#" ]] && continue
19
- >
20
- > if [[ "$line" =~ ^(-{1,2}[^[:space:]]+)[[:space:]]+(.+)$ ]]; then
21
- > for arg in "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}"; do
22
- > arg="${arg#"${arg%%[![:space:]]*}"}"
23
- > arg="${arg%"${arg##*[![:space:]]}"}"
24
- > [[ "$arg" =~ ^\"(.*)\"$ || "$arg" =~ ^\'(.*)\'$ ]] && arg="${BASH_REMATCH[1]}"
25
- > argfile_input+=("$arg")
26
- > done
27
- > else
28
- > arg="$line"
29
- > [[ "$arg" =~ ^\"(.*)\"$ || "$arg" =~ ^\'(.*)\'$ ]] && arg="${BASH_REMATCH[1]}"
30
- > argfile_input+=("$arg")
31
- > fi
32
- > done <"$argfile_path"
33
- >
34
- > argfile_input+=("$@")
35
- > }
36
- >