File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
1
module Bashly
2
2
# This is a `Command` concern responsible for providing additional scopes.
3
3
module CommandScopes
4
- # Returns an array of all full names (including aliases)
4
+ # Returns an array of all full names (including aliases and aliases of
5
+ # parents)
5
6
def all_full_names
6
- [ full_name ] + if parents . any?
7
- alt . map { |a | ( parents + [ a ] ) . join ( ' ' ) }
7
+ if parent_command
8
+ parent_command . all_full_names . product ( aliases ) . map { |a | a . join ' ' }
8
9
else
9
- alt
10
+ aliases
10
11
end
11
12
end
12
13
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ def commands
62
62
return [ ] unless options [ "commands" ]
63
63
options [ "commands" ] . map do |options |
64
64
options [ 'parents' ] = parents + [ name ]
65
+ options [ 'parent_command' ] = self
65
66
Command . new options
66
67
end
67
68
end
@@ -116,6 +117,11 @@ def load_user_file(file, placeholder: true)
116
117
Settings . production? ? content : "#{ view_marker path } \n #{ content } "
117
118
end
118
119
120
+ # Returns the Command instance of the direct parent
121
+ def parent_command
122
+ options [ 'parent_command' ]
123
+ end
124
+
119
125
# Returns an array of all parents. For example, the command
120
126
# "docker container run" will have [docker, container] as its parents
121
127
def parents
You can’t perform that action at this time.
0 commit comments