@@ -2,6 +2,7 @@ module Bashly
22 module Script
33 class Command < Base
44 include Completions
5+ include CommandScopes
56
67 # Returns the name to be used as an action.
78 # - If it is the root command, the action is "root"
@@ -34,11 +35,6 @@ def catch_all
3435 @catch_all ||= CatchAll . from_config options [ 'catch_all' ]
3536 end
3637
37- # Returns only the names of the Commands
38- def command_names
39- commands . map &:name
40- end
41-
4238 # Returns an array of the Commands
4339 def commands
4440 return [ ] unless options [ "commands" ]
@@ -48,40 +44,6 @@ def commands
4844 end
4945 end
5046
51- # Returns a flat array containing all the commands in this tree.
52- # This includes self + children + grandchildres + ...
53- def deep_commands
54- result = [ ]
55- commands . each do |command |
56- result << command
57- if command . commands . any?
58- result += command . deep_commands
59- end
60- end
61- result
62- end
63-
64- # Returns an array of all the default Args
65- def default_args
66- args . select &:default
67- end
68-
69- # If any of this command's subcommands has the default option set to
70- # true, this default command will be returned, nil otherwise.
71- def default_command
72- commands . find { |c | c . default }
73- end
74-
75- # Returns an array of all the default Environment Variables
76- def default_environment_variables
77- environment_variables . select &:default
78- end
79-
80- # Returns an array of all the default Flags
81- def default_flags
82- flags . select &:default
83- end
84-
8547 # Returns an array of EnvironmentVariables
8648 def environment_variables
8749 return [ ] unless options [ "environment_variables" ]
@@ -137,21 +99,6 @@ def parents
13799 options [ 'parents' ] || [ ]
138100 end
139101
140- # Returns an array of all the required Arguments
141- def required_args
142- args . select &:required
143- end
144-
145- # Returns an array of all the required EnvironmentVariables
146- def required_environment_variables
147- environment_variables . select &:required
148- end
149-
150- # Returns an array of all the required Flags
151- def required_flags
152- flags . select &:required
153- end
154-
155102 # Returns trus if this is the root command (no parents)
156103 def root_command?
157104 parents . empty?
@@ -187,16 +134,6 @@ def validate_options
187134 Bashly ::ConfigValidator . new ( options ) . validate
188135 end
189136
190- # Returns an array of all the args with a whitelist
191- def whitelisted_args
192- args . select &:allowed
193- end
194-
195- # Returns an array of all the flags with a whitelist arg
196- def whitelisted_flags
197- flags . select &:allowed
198- end
199-
200137 end
201138 end
202139end
0 commit comments