@@ -2,6 +2,7 @@ module Bashly
2
2
module Script
3
3
class Command < Base
4
4
include Completions
5
+ include CommandScopes
5
6
6
7
# Returns the name to be used as an action.
7
8
# - If it is the root command, the action is "root"
@@ -34,11 +35,6 @@ def catch_all
34
35
@catch_all ||= CatchAll . from_config options [ 'catch_all' ]
35
36
end
36
37
37
- # Returns only the names of the Commands
38
- def command_names
39
- commands . map &:name
40
- end
41
-
42
38
# Returns an array of the Commands
43
39
def commands
44
40
return [ ] unless options [ "commands" ]
@@ -48,40 +44,6 @@ def commands
48
44
end
49
45
end
50
46
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
-
85
47
# Returns an array of EnvironmentVariables
86
48
def environment_variables
87
49
return [ ] unless options [ "environment_variables" ]
@@ -137,21 +99,6 @@ def parents
137
99
options [ 'parents' ] || [ ]
138
100
end
139
101
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
-
155
102
# Returns trus if this is the root command (no parents)
156
103
def root_command?
157
104
parents . empty?
@@ -187,16 +134,6 @@ def validate_options
187
134
Bashly ::ConfigValidator . new ( options ) . validate
188
135
end
189
136
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
-
200
137
end
201
138
end
202
139
end
0 commit comments