bashly 1.4.0 → 2.0.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bashly/commands/completions.rb +3 -41
  3. data/lib/bashly/completions/README.md +3 -7
  4. data/lib/bashly/completions/bashly-completions.bash +2 -2
  5. data/lib/bashly/completions/completely.yaml +0 -4
  6. data/lib/bashly/config_validator.rb +16 -3
  7. data/lib/bashly/docs/arg.yml +12 -6
  8. data/lib/bashly/docs/command.yml +0 -12
  9. data/lib/bashly/docs/flag.yml +8 -4
  10. data/lib/bashly/libraries/libraries.yml +0 -15
  11. data/lib/bashly/libraries/settings/settings.yml +9 -1
  12. data/lib/bashly/script/argument.rb +12 -0
  13. data/lib/bashly/script/command.rb +1 -2
  14. data/lib/bashly/script/flag.rb +12 -1
  15. data/lib/bashly/script/introspection/commands.rb +5 -0
  16. data/lib/bashly/script/wrapper.rb +1 -1
  17. data/lib/bashly/settings.rb +28 -3
  18. data/lib/bashly/version.rb +1 -1
  19. data/lib/bashly/views/argument/completion.gtx +31 -0
  20. data/lib/bashly/views/argument/completion_filter.gtx +1 -0
  21. data/lib/bashly/views/command/completion_argument_candidates.gtx +11 -0
  22. data/lib/bashly/views/command/completion_argument_filter.gtx +25 -0
  23. data/lib/bashly/views/command/completion_command_candidates.gtx +3 -0
  24. data/lib/bashly/views/command/completion_flag_candidates.gtx +21 -0
  25. data/lib/bashly/views/command/completion_function.gtx +24 -0
  26. data/lib/bashly/views/command/completion_script.gtx +21 -0
  27. data/lib/bashly/views/command/completion_script_bash.gtx +63 -0
  28. data/lib/bashly/views/command/completion_script_zsh.gtx +52 -0
  29. data/lib/bashly/views/command/completion_word_filter.gtx +44 -0
  30. data/lib/bashly/views/command/completions.gtx +81 -0
  31. data/lib/bashly/views/command/inspect_args.gtx +3 -3
  32. data/lib/bashly/views/command/master_script.gtx +1 -0
  33. data/lib/bashly/views/command/start.gtx +9 -0
  34. data/lib/bashly/views/flag/completion.gtx +1 -0
  35. data/lib/bashly/views/flag/completion_filter.gtx +7 -0
  36. data/lib/bashly/views/flag/completion_filter_arg.gtx +10 -0
  37. data/lib/bashly/views/flag/completion_filter_block.gtx +8 -0
  38. data/lib/bashly/views/flag/completion_filter_no_arg.gtx +2 -0
  39. data/lib/bashly/views/flag/completion_value_candidates.gtx +31 -0
  40. data/lib/bashly.rb +2 -5
  41. metadata +22 -23
  42. data/lib/bashly/completion_builder.rb +0 -231
  43. data/lib/bashly/concerns/completions.rb +0 -48
  44. data/lib/bashly/libraries/completions/completions_function.rb +0 -37
  45. data/lib/bashly/libraries/completions/completions_script.rb +0 -28
  46. data/lib/bashly/libraries/completions/completions_yaml.rb +0 -26
  47. /data/lib/bashly/views/wrapper/{bash3_bouncer.gtx → bash_version_bouncer.gtx} +0 -0
@@ -1,48 +0,0 @@
1
- require 'completely'
2
- require 'bashly/completion_builder'
3
-
4
- module Bashly
5
- # This is a `Command` and `Flag` concern responsible for providing bash
6
- # completion data
7
- module Completions
8
- module Flag
9
- def completion_data(command_full_name)
10
- comps = allowed || completions
11
- return {} unless comps
12
-
13
- aliases.to_h do |name|
14
- prefix = command_full_name
15
- prefix = "#{prefix}*" unless prefix.end_with? '*'
16
- ["#{prefix}#{name}", comps]
17
- end
18
- end
19
-
20
- def completion_option_entry(token_name = nil)
21
- result = [aliases.join('|')]
22
- result << "<#{token_name}>" if token_name
23
- result << '(repeatable)' if repeatable
24
- result.join ' '
25
- end
26
- end
27
-
28
- module Command
29
- def completion_data(with_version: true)
30
- CompletionBuilder.new(self, with_version: with_version).call
31
- end
32
-
33
- def completion_script
34
- completion_generator.script
35
- end
36
-
37
- def completion_function(name = nil)
38
- completion_generator.wrapper_function name
39
- end
40
-
41
- private
42
-
43
- def completion_generator
44
- Completely::Completions.new completion_data
45
- end
46
- end
47
- end
48
- end
@@ -1,37 +0,0 @@
1
- module Bashly
2
- module Libraries
3
- class CompletionsFunction < Base
4
- def files
5
- [
6
- {
7
- path: "#{Settings.full_lib_dir}/#{function_name}.#{Settings.partials_extension}",
8
- content: completions_function_code(function_name),
9
- },
10
- ]
11
- end
12
-
13
- def post_install_message
14
- <<~MESSAGE
15
- In order to enable completions in your script, create a command or a flag (for example: g`#{command.name} completions` or g`#{command.name} --completions`) that calls the g`#{function_name}` function.
16
-
17
- Your users can then run something like this to enable completions:
18
-
19
- m`$ eval "$(#{command.name} completions)"`
20
- MESSAGE
21
- end
22
-
23
- private
24
-
25
- def function_name
26
- @function_name ||= args[0] || 'send_completions'
27
- end
28
-
29
- def completions_function_code(function_name)
30
- [
31
- "## [@bashly-upgrade completions #{function_name}]",
32
- command.completion_function(function_name),
33
- ].join "\n"
34
- end
35
- end
36
- end
37
- end
@@ -1,28 +0,0 @@
1
- module Bashly
2
- module Libraries
3
- class CompletionsScript < Base
4
- def files
5
- [
6
- {
7
- path: target_path,
8
- content: command.completion_script,
9
- },
10
- ]
11
- end
12
-
13
- def post_install_message
14
- <<~MESSAGE
15
- In order to enable completions, run:
16
-
17
- m`$ source #{target_path}`
18
- MESSAGE
19
- end
20
-
21
- private
22
-
23
- def target_path
24
- @target_path ||= args[0] || "#{Settings.target_dir}/completions.bash"
25
- end
26
- end
27
- end
28
- end
@@ -1,26 +0,0 @@
1
- module Bashly
2
- module Libraries
3
- class CompletionsYAML < Base
4
- def files
5
- [
6
- {
7
- path: target_path,
8
- content: command.completion_data.to_yaml,
9
- },
10
- ]
11
- end
12
-
13
- def post_install_message
14
- <<~MESSAGE
15
- This file can be converted to a completions script using the g`completely` gem.
16
- MESSAGE
17
- end
18
-
19
- private
20
-
21
- def target_path
22
- @target_path ||= args[0] || "#{Settings.target_dir}/completions.yml"
23
- end
24
- end
25
- end
26
- end