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 11module Bashly
22 # This is a `Command` concern responsible for providing additional scopes.
33 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)
56 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 ' ' }
89 else
9- alt
10+ aliases
1011 end
1112 end
1213
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ def commands
6262 return [ ] unless options [ "commands" ]
6363 options [ "commands" ] . map do |options |
6464 options [ 'parents' ] = parents + [ name ]
65+ options [ 'parent_command' ] = self
6566 Command . new options
6667 end
6768 end
@@ -116,6 +117,11 @@ def load_user_file(file, placeholder: true)
116117 Settings . production? ? content : "#{ view_marker path } \n #{ content } "
117118 end
118119
120+ # Returns the Command instance of the direct parent
121+ def parent_command
122+ options [ 'parent_command' ]
123+ end
124+
119125 # Returns an array of all parents. For example, the command
120126 # "docker container run" will have [docker, container] as its parents
121127 def parents
You can’t perform that action at this time.
0 commit comments