bashly 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bashly/commands/shell.rb +1 -1
  3. data/lib/bashly/concerns/completions.rb +3 -3
  4. data/lib/bashly/docs/env.yml +10 -0
  5. data/lib/bashly/docs/flag.yml +23 -0
  6. data/lib/bashly/libraries/ini/ini.sh +1 -0
  7. data/lib/bashly/libraries/render/mandoc/mandoc.gtx +7 -4
  8. data/lib/bashly/libraries/render/markdown/markdown.gtx +7 -3
  9. data/lib/bashly/libraries/settings/settings.yml +5 -0
  10. data/lib/bashly/libraries/strings/strings.yml +4 -0
  11. data/lib/bashly/script/command.rb +9 -208
  12. data/lib/bashly/script/environment_variable.rb +5 -1
  13. data/lib/bashly/script/flag.rb +5 -2
  14. data/lib/bashly/script/introspection/arguments.rb +41 -0
  15. data/lib/bashly/script/introspection/commands.rb +111 -0
  16. data/lib/bashly/script/introspection/dependencies.rb +16 -0
  17. data/lib/bashly/script/introspection/environment_variables.rb +47 -0
  18. data/lib/bashly/script/introspection/examples.rb +14 -0
  19. data/lib/bashly/script/introspection/flags.rb +58 -0
  20. data/lib/bashly/script/introspection/visibility.rb +19 -0
  21. data/lib/bashly/settings.rb +5 -0
  22. data/lib/bashly/version.rb +1 -1
  23. data/lib/bashly/views/argument/usage.gtx +3 -3
  24. data/lib/bashly/views/command/environment_variables_filter.gtx +6 -0
  25. data/lib/bashly/views/command/fixed_flags_filter.gtx +2 -1
  26. data/lib/bashly/views/command/long_usage.gtx +8 -4
  27. data/lib/bashly/views/command/needy_flags_filter.gtx +9 -0
  28. data/lib/bashly/views/command/parse_requirements.gtx +1 -0
  29. data/lib/bashly/views/command/usage_commands.gtx +10 -3
  30. data/lib/bashly/views/command/usage_environment_variables.gtx +20 -4
  31. data/lib/bashly/views/command/usage_flags.gtx +10 -2
  32. data/lib/bashly/views/environment_variable/usage.gtx +2 -2
  33. data/lib/bashly/views/environment_variable/validations.gtx +9 -0
  34. data/lib/bashly/views/flag/needs.gtx +22 -0
  35. data/lib/bashly/views/flag/usage.gtx +11 -3
  36. data/lib/bashly.rb +27 -40
  37. metadata +67 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36c0868dbf2a0e4d5d2fecdc5854aac4e1bea8f7953a07712ccc985289c89b57
4
- data.tar.gz: 63df3d720e1b36ce7ab658224fde796fb9460c92c7946bd867204c0e0caea304
3
+ metadata.gz: 725e002cebc500c79119085ec0d2f7bdb30b714a5f3a258231e4cdbe31d58a8e
4
+ data.tar.gz: 238fb5a417387d63a3ad327cead7ecea9e88a96e2944220f2709155513ce2095
5
5
  SHA512:
6
- metadata.gz: 39e367d86e8bf21ae076c35887157234e7d39d003f17a596aa4711a02a87c6b3856ac27b0f1c73c30837b2589358e479c069dba4cff657431fdca98f44116718
7
- data.tar.gz: eceaabeafea2e93a9cf7c9d7c2f999a2303c0d9172ddd7799bb0d1f9eafe62166ee9512d8688ad9cc6547dd28e20b7c8925ca489cb2639fd3cd2456517461e7a
6
+ metadata.gz: e9f50c76e011350a5e687f5e9262dee12fcd408801b3fe1fb367ffc36e5d132c564549f0204d32e74f7fb5bc8a034d621be6ec282dd4d3373f4936031a849ebf
7
+ data.tar.gz: 488dc7677fdf54c8402abd94c3f5105295b751964531229b9313c54508fe63f64bbe428ae583eac4ec9ba8aaa25147b9eb0df55baec3d10978a3797447c6e2cf
@@ -19,7 +19,7 @@ module Bashly
19
19
  terminal = MisterBin::Terminal.new runner, {
20
20
  autocomplete: autocomplete,
21
21
  show_usage: true,
22
- prompt: "$ bashly ",
22
+ prompt: '$ bashly ',
23
23
  }
24
24
 
25
25
  terminal.on('help') { runner.run %w[--help] }
@@ -29,7 +29,7 @@ module Bashly
29
29
  end
30
30
  end
31
31
 
32
- public_commands.each do |command|
32
+ visible_commands.each do |command|
33
33
  result.merge! command.completion_data(with_version: false)
34
34
  end
35
35
 
@@ -62,7 +62,7 @@ module Bashly
62
62
  end
63
63
 
64
64
  def completion_flag_names
65
- public_flags.map(&:name) + public_flags.map(&:short)
65
+ visible_flags.map(&:name) + visible_flags.map(&:short)
66
66
  end
67
67
 
68
68
  def completion_allowed_args
@@ -73,7 +73,7 @@ module Bashly
73
73
  trivial_flags = %w[--help -h]
74
74
  trivial_flags += %w[--version -v] if with_version
75
75
  all = (
76
- public_command_aliases + trivial_flags +
76
+ visible_command_aliases + trivial_flags +
77
77
  completion_flag_names + completion_allowed_args
78
78
  )
79
79
 
@@ -49,6 +49,16 @@ environment_variable.required:
49
49
  help: Specify that this variable is required.
50
50
  url: https://bashly.dannyb.co/configuration/environment-variable/#required
51
51
  example: |-
52
+ environment_variables:
52
53
  - name: api_key
53
54
  help: Your API key
54
55
  required: true
56
+
57
+ environment_variable.validate:
58
+ help: Apply custom validation functions.
59
+
60
+ url: https://bashly.dannyb.co/configuration/environment-variable/#validate
61
+ example: |-
62
+ environment_variables:
63
+ - name: build_dir
64
+ validate: dir_exists
@@ -113,6 +113,29 @@ flag.long:
113
113
  short: -s
114
114
  help: Clone using SSH
115
115
 
116
+ flag.needs:
117
+ help: Specify that this flag needs one or more additional flags. Use the long name of these needed flags.
118
+ url: https://bashly.dannyb.co/configuration/flag/#needs
119
+ example: |-
120
+ flags:
121
+ - long: --add
122
+ arg: alias
123
+
124
+ # When using --add, --command and --target must also be provided
125
+ needs: [--command, --target]
126
+
127
+ - long: --command
128
+ arg: command
129
+ help: Command for the alias
130
+
131
+ # Note that this relationship is marked on both sides
132
+ needs: [--add]
133
+
134
+ - long: --target
135
+ arg: target
136
+ help: Where to add the alias
137
+ needs: [--add]
138
+
116
139
  flag.private:
117
140
  help: Specify that this flag should not be displayed in the help text.
118
141
  url: https://bashly.dannyb.co/configuration/flag/#private
@@ -27,6 +27,7 @@
27
27
  ##
28
28
  ## Load an INI file and populate the associative array `ini`.
29
29
  ini_load() {
30
+ unset ini
30
31
  declare -gA ini
31
32
 
32
33
  local ini_file="$1"
@@ -43,7 +43,7 @@ if extensible
43
43
  end
44
44
  >
45
45
 
46
- if public_commands.any?
46
+ if visible_commands.any?
47
47
  grouped_commands.each do |group, commands|
48
48
  > {{ group.gsub(/:$/, '').upcase }}
49
49
  > ==================================================
@@ -127,6 +127,9 @@ if flags.any?
127
127
  if flag.conflicts
128
128
  > - Conflicts With: **{{ flag.conflicts.join(', ') }}**
129
129
  end
130
+ if flag.needs
131
+ > - Needs: **{{ flag.needs.join(', ') }}**
132
+ end
130
133
  >
131
134
  end
132
135
  end
@@ -147,11 +150,11 @@ if dependencies.any?
147
150
  end
148
151
  end
149
152
 
150
- if public_environment_variables.any?
153
+ if visible_environment_variables.any?
151
154
  > ENVIRONMENT VARIABLES
152
155
  > ==================================================
153
156
  >
154
- public_environment_variables.each do |environment_variable|
157
+ visible_environment_variables.each do |environment_variable|
155
158
  > {{ environment_variable.name.upcase }}
156
159
  > --------------------------------------------------
157
160
  >
@@ -183,7 +186,7 @@ end
183
186
 
184
187
  see_also = []
185
188
  see_also << parents.first if parents.any?
186
- see_also += public_commands.map { |x| x.full_name.to_hyphen } if public_commands.any?
189
+ see_also += visible_commands.map { |x| x.full_name.to_hyphen } if visible_commands.any?
187
190
  see_also += x_mandoc_see_also if x_mandoc_see_also && x_mandoc_see_also.is_a?(Array)
188
191
  see_also.map! do |item|
189
192
  item.match(/(.+)(\(\d\))/) ? "**#{$1}**#{$2}" : "**#{item}**(1)"
@@ -62,10 +62,10 @@ end
62
62
 
63
63
  # === Environment Variables
64
64
 
65
- if public_environment_variables.any?
65
+ if visible_environment_variables.any?
66
66
  > ## Environment Variables
67
67
  >
68
- public_environment_variables.each do |environment_variable|
68
+ visible_environment_variables.each do |environment_variable|
69
69
  attributes = environment_variable.required || environment_variable.default
70
70
 
71
71
  > #### *{{ environment_variable.name.upcase }}*
@@ -152,7 +152,8 @@ if flags.any?
152
152
  > ## Options
153
153
  >
154
154
  flags.each do |flag|
155
- attributes = flag.required || flag.repeatable || flag.default || flag.allowed || flag.conflicts
155
+ attributes = flag.required || flag.repeatable || flag.default ||
156
+ flag.allowed || flag.conflicts || flag.needs
156
157
 
157
158
  > #### *{{ flag.usage_string }}*
158
159
  >
@@ -177,6 +178,9 @@ if flags.any?
177
178
  if flag.conflicts
178
179
  > | Conflicts With: | *{{ flag.conflicts.join(', ') }}*
179
180
  end
181
+ if flag.needs
182
+ > | Needs: | *{{ flag.needs.join(', ') }}*
183
+ end
180
184
  >
181
185
  end
182
186
  end
@@ -59,6 +59,11 @@ partials_extension: sh
59
59
  # required arguments
60
60
  show_examples_on_error: false
61
61
 
62
+ # When using private commands, flags, or environment variables, you may set
63
+ # this option to a name of an environment variable that, if set, will reveal
64
+ # all the private elements in the usage texts, as if they were public.
65
+ private_reveal_key: ~
66
+
62
67
  # Display various usage elements in color by providing the name of the color
63
68
  # function. The value for each property is a name of a function that is
64
69
  # available in your script, for example: `green` or `bold`.
@@ -18,6 +18,8 @@ required: "(required)"
18
18
  repeatable: "(repeatable)"
19
19
  default: "Default: %{value}"
20
20
  allowed: "Allowed: %{values}"
21
+ needs: "Needs: %{values}"
22
+ conflicts: "Conflicts: %{values}"
21
23
 
22
24
  # Fixed flags help text
23
25
  help_flag_text: Show this help
@@ -25,6 +27,7 @@ version_flag_text: Show version number
25
27
 
26
28
  # Error messages
27
29
  flag_requires_an_argument: "%{name} requires an argument: %{usage}"
30
+ flag_needs_another: "%{name} needs %{need}"
28
31
  invalid_argument: "invalid argument: %s"
29
32
  invalid_flag: "invalid option: %s"
30
33
  invalid_command: "invalid command: %s"
@@ -39,3 +42,4 @@ disallowed_argument: "%{name} must be one of: %{allowed}"
39
42
  disallowed_environment_variable: "%{name} environment variable must be one of: %{allowed}"
40
43
  unsupported_bash_version: "bash version 4 or higher is required"
41
44
  validation_error: "validation error in %s:\\n%s"
45
+ environment_variable_validation_error: "validation error in environment variable %s:\\n%s"
@@ -2,6 +2,13 @@ module Bashly
2
2
  module Script
3
3
  class Command < Base
4
4
  include Completions::Command
5
+ include Introspection::Arguments
6
+ include Introspection::Commands
7
+ include Introspection::Dependencies
8
+ include Introspection::EnvironmentVariables
9
+ include Introspection::Examples
10
+ include Introspection::Flags
11
+ include Introspection::Visibility
5
12
 
6
13
  class << self
7
14
  def option_keys
@@ -39,15 +46,6 @@ module Bashly
39
46
  options['alias'].is_a?(String) ? [options['alias']] : options['alias']
40
47
  end
41
48
 
42
- # Returns an array of Arguments
43
- def args
44
- return [] unless options['args']
45
-
46
- options['args'].map do |options|
47
- Argument.new options
48
- end
49
- end
50
-
51
49
  # Returns a string suitable to be a headline
52
50
  def caption_string
53
51
  help.empty? ? full_name : "#{full_name} - #{summary}"
@@ -58,123 +56,12 @@ module Bashly
58
56
  @catch_all ||= CatchAll.from_config options['catch_all']
59
57
  end
60
58
 
61
- # Returns a full list of the Command names and aliases combined
62
- def command_aliases
63
- commands.map(&:aliases).flatten
64
- end
65
-
66
- # Returns a data structure for displaying subcommands help
67
- def command_help_data
68
- result = {}
69
-
70
- public_commands.each do |command|
71
- result[command.group_string] ||= {}
72
- result[command.group_string][command.name] = { summary: command.summary_string }
73
- next unless command.expose
74
-
75
- command.public_commands.each do |subcommand|
76
- result[command.group_string]["#{command.name} #{subcommand.name}"] = {
77
- summary: subcommand.summary_string,
78
- help_only: command.expose != 'always',
79
- }
80
- end
81
- end
82
-
83
- result
84
- end
85
-
86
- # Returns only the names of the Commands
87
- def command_names
88
- commands.map(&:name)
89
- end
90
-
91
- # Returns an array of the Commands
92
- def commands
93
- return [] unless options['commands']
94
-
95
- options['commands'].map do |options|
96
- result = Command.new options
97
- result.parents = parents + [name]
98
- result.parent_command = self
99
- result
100
- end
101
- end
102
-
103
- # Returns a flat array containing all the commands in this tree.
104
- # This includes children + grandchildren (recursive), and may include self
105
- def deep_commands(include_self: false)
106
- result = []
107
- result << self if include_self
108
- commands.each do |command|
109
- result << command
110
- if command.commands.any?
111
- result += command.deep_commands
112
- end
113
- end
114
- result
115
- end
116
-
117
- # If any of this command's subcommands has the default option set to
118
- # true, this default command will be returned, nil otherwise.
119
- def default_command
120
- commands.find(&:default)
121
- end
122
-
123
- # Returns an array of all the default Args
124
- def default_args
125
- args.select(&:default)
126
- end
127
-
128
- # Returns an array of all the default Environment Variables
129
- def default_environment_variables
130
- environment_variables.select(&:default)
131
- end
132
-
133
- # Returns an array of all the default Flags
134
- def default_flags
135
- flags.select(&:default)
136
- end
137
-
138
- # Returns an array of Dependency objects
139
- def dependencies
140
- return [] unless options['dependencies']
141
-
142
- @dependencies ||= options['dependencies'].map do |key, value|
143
- Dependency.from_config key, value
144
- end
145
- end
146
-
147
- # Returns an array of EnvironmentVariable objects
148
- def environment_variables
149
- return [] unless options['environment_variables']
150
-
151
- options['environment_variables'].map do |options|
152
- EnvironmentVariable.new options
153
- end
154
- end
155
-
156
- # Returns an array of examples
157
- def examples
158
- return nil unless options['examples']
159
-
160
- options['examples'].is_a?(Array) ? options['examples'] : [options['examples']]
161
- end
162
-
163
59
  # Returns the filename that is expected to hold the user code for this
164
60
  # command
165
61
  def filename
166
62
  options['filename'] || implicit_filename
167
63
  end
168
64
 
169
- # Returns an array of Flags
170
- def flags
171
- return [] unless options['flags']
172
-
173
- options['flags'].map do |options|
174
- Flag.new options
175
- end
176
- end
177
-
178
65
  # Returns a unique name, suitable to be used in a bash function
179
66
  def function_name
180
67
  options['function'] || full_name.to_underscore
@@ -186,12 +73,6 @@ module Bashly
186
73
  parents.any? ? (parents + [name]).join(' ') : name
187
74
  end
188
75
 
189
- # Returns true if this command's flags should be considered as gloal
190
- # flags, and cascade to subcommands
191
- def global_flags?
192
- flags.any? and commands.any?
193
- end
194
-
195
76
  # Returns the string for the group caption
196
77
  def group_string
197
78
  if group
@@ -201,23 +82,6 @@ module Bashly
201
82
  end
202
83
  end
203
84
 
204
- # Returns subcommands by group
205
- def grouped_commands
206
- result = {}
207
-
208
- public_commands.each do |command|
209
- result[command.group_string] ||= []
210
- result[command.group_string] << command
211
- next unless command.expose
212
-
213
- command.public_commands.each do |subcommand|
214
- result[command.group_string] << subcommand
215
- end
216
- end
217
-
218
- result
219
- end
220
-
221
85
  # Returns true if this command, or any subcommand (deep) as any arg or
222
86
  # flag with arg that is defined as unique
223
87
  def has_unique_args_or_flags?
@@ -246,56 +110,11 @@ module Bashly
246
110
  @parents ||= []
247
111
  end
248
112
 
249
- # Returns only commands that are not private
250
- def public_commands
251
- commands.reject(&:private)
252
- end
253
-
254
- # Returns a full list of the public Command names and aliases combined
255
- def public_command_aliases
256
- public_commands.map(&:aliases).flatten
257
- end
258
-
259
- # Returns only environment variables that are not private
260
- def public_environment_variables
261
- environment_variables.reject(&:private)
262
- end
263
-
264
- # Returns only flags that are not private
265
- def public_flags
266
- flags.reject(&:private)
267
- end
268
-
269
- # Returns true if one of the args is repeatable
270
- def repeatable_arg_exist?
271
- args.any?(&:repeatable)
272
- end
273
-
274
- # Returns an array of all the required Arguments
275
- def required_args
276
- args.select(&:required)
277
- end
278
-
279
- # Returns an array of all the required EnvironmentVariables
280
- def required_environment_variables
281
- environment_variables.select(&:required)
282
- end
283
-
284
- # Returns an array of all the required Flags
285
- def required_flags
286
- flags.select(&:required)
287
- end
288
-
289
113
  # Returns true if this is the root command (no parents)
290
114
  def root_command?
291
115
  parents.empty?
292
116
  end
293
117
 
294
- # Returns true if one of the flags matches the provided short code
295
- def short_flag_exist?(flag)
296
- flags.any? { |f| f.short == flag }
297
- end
298
-
299
118
  # Returns the summary string
300
119
  def summary_string
301
120
  if default
@@ -322,11 +141,8 @@ module Bashly
322
141
  result.compact.join ' '
323
142
  end
324
143
 
325
- # Returns an array of args usage_string for the command's usage_string
326
- def usage_string_args
327
- args.map(&:usage_string)
328
- end
329
-
144
+ # Returns a base usage string that considers whether this command is the
145
+ # default, and if it has any parents. Used internally by `usage_string`.
330
146
  def base_usage_pattern
331
147
  usage_pattern = default ? "[#{name}]" : name
332
148
  parents.any? ? (parents + [usage_pattern]).join(' ') : usage_pattern
@@ -344,21 +160,6 @@ module Bashly
344
160
  @validatables ||= args.select(&:validate) + flags.select(&:validate)
345
161
  end
346
162
 
347
- # Returns an array of all the args with a whitelist
348
- def whitelisted_args
349
- args.select(&:allowed)
350
- end
351
-
352
- # Returns an array of all the environment_variables with a whitelist arg
353
- def whitelisted_environment_variables
354
- environment_variables.select(&:allowed)
355
- end
356
-
357
- # Returns an array of all the flags with a whitelist arg
358
- def whitelisted_flags
359
- flags.select(&:allowed)
360
- end
361
-
362
163
  private
363
164
 
364
165
  # Returns either a flat filename (docker_status_command.sh) or a nested
@@ -1,9 +1,13 @@
1
1
  module Bashly
2
2
  module Script
3
3
  class EnvironmentVariable < Base
4
+ include Introspection::Visibility
5
+
4
6
  class << self
5
7
  def option_keys
6
- @option_keys ||= %i[allowed default help name required private]
8
+ @option_keys ||= %i[
9
+ allowed default help name required private validate
10
+ ]
7
11
  end
8
12
  end
9
13
 
@@ -1,13 +1,16 @@
1
+ require 'shellwords'
2
+
1
3
  module Bashly
2
4
  module Script
3
5
  class Flag < Base
4
6
  include Completions::Flag
7
+ include Introspection::Visibility
5
8
 
6
9
  class << self
7
10
  def option_keys
8
11
  @option_keys ||= %i[
9
- allowed arg completions conflicts default help long repeatable
10
- required short unique validate private
12
+ allowed arg completions conflicts default help long needs
13
+ repeatable required short unique validate private
11
14
  ]
12
15
  end
13
16
  end
@@ -0,0 +1,41 @@
1
+ module Bashly
2
+ module Script
3
+ module Introspection
4
+ module Arguments
5
+ # Returns an array of Arguments
6
+ def args
7
+ return [] unless options['args']
8
+
9
+ options['args'].map do |options|
10
+ Argument.new options
11
+ end
12
+ end
13
+
14
+ # Returns an array of all the default Args
15
+ def default_args
16
+ args.select(&:default)
17
+ end
18
+
19
+ # Returns true if one of the args is repeatable
20
+ def repeatable_arg_exist?
21
+ args.any?(&:repeatable)
22
+ end
23
+
24
+ # Returns an array of all the required Arguments
25
+ def required_args
26
+ args.select(&:required)
27
+ end
28
+
29
+ # Returns an array of args usage_string for the command's usage_string
30
+ def usage_string_args
31
+ args.map(&:usage_string)
32
+ end
33
+
34
+ # Returns an array of all the args with a whitelist
35
+ def whitelisted_args
36
+ args.select(&:allowed)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,111 @@
1
+ module Bashly
2
+ module Script
3
+ module Introspection
4
+ module Commands
5
+ # Returns a full list of the Command names and aliases combined
6
+ def command_aliases
7
+ commands.map(&:aliases).flatten
8
+ end
9
+
10
+ # Returns a data structure for displaying subcommands help
11
+ def command_help_data
12
+ result = {}
13
+
14
+ commands.each do |command|
15
+ result[command.group_string] ||= {}
16
+ result[command.group_string][command.name] = {
17
+ summary: command.summary_string,
18
+ visibility: command.visibility,
19
+ }
20
+ next unless command.expose
21
+
22
+ command.commands.each do |subcommand|
23
+ result[command.group_string]["#{command.name} #{subcommand.name}"] = {
24
+ summary: subcommand.summary_string,
25
+ visibility: subcommand.visibility,
26
+ help_only: command.expose != 'always',
27
+ }
28
+ end
29
+ end
30
+
31
+ result
32
+ end
33
+
34
+ # Returns only the names of the Commands
35
+ def command_names
36
+ commands.map(&:name)
37
+ end
38
+
39
+ # Returns an array of the Commands
40
+ def commands
41
+ return [] unless options['commands']
42
+
43
+ options['commands'].map do |options|
44
+ result = Command.new options
45
+ result.parents = parents + [name]
46
+ result.parent_command = self
47
+ result
48
+ end
49
+ end
50
+
51
+ # Returns a flat array containing all the commands in this tree.
52
+ # This includes children + grandchildren (recursive), and may include self
53
+ def deep_commands(include_self: false)
54
+ result = []
55
+ result << self if include_self
56
+ commands.each do |command|
57
+ result << command
58
+ if command.commands.any?
59
+ result += command.deep_commands
60
+ end
61
+ end
62
+ result
63
+ end
64
+
65
+ # If any of this command's subcommands has the default option set to
66
+ # true, this default command will be returned, nil otherwise.
67
+ def default_command
68
+ commands.find(&:default)
69
+ end
70
+
71
+ # Returns subcommands by group
72
+ def grouped_commands
73
+ result = {}
74
+
75
+ visible_commands.each do |command|
76
+ result[command.group_string] ||= []
77
+ result[command.group_string] << command
78
+ next unless command.expose
79
+
80
+ command.visible_commands.each do |subcommand|
81
+ result[command.group_string] << subcommand
82
+ end
83
+ end
84
+
85
+ result
86
+ end
87
+
88
+ # Returns only commands that are not private
89
+ def public_commands
90
+ commands.reject(&:private)
91
+ end
92
+
93
+ # Returns a full list of the public Command names and aliases combined
94
+ def public_command_aliases
95
+ public_commands.map(&:aliases).flatten
96
+ end
97
+
98
+ # Returns only public commands, or both public and private commands
99
+ # if Settings.private_reveal_key is set
100
+ def visible_commands
101
+ Settings.private_reveal_key ? commands : public_commands
102
+ end
103
+
104
+ # Returns a full list of the visible Command names and aliases combined
105
+ def visible_command_aliases
106
+ visible_commands.map(&:aliases).flatten
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end