Skip to content

Commit d7ea262

Browse files
committed
- Fix completions for deep command aliases
1 parent 8b86cfc commit d7ea262

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/bashly/concerns/command_scopes.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module 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

lib/bashly/script/command.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)