Skip to content

Commit f379199

Browse files
committed
Use map entry Aliases for command-level remap
1 parent 0219da9 commit f379199

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

pkg/cli/plugin_cmd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ func getCmdForPluginEx(p *PluginInfo, cmdName string, mapEntry *plugin.CommandMa
115115

116116
// is not a toplevel command
117117
if len(srcHierarchy) > 0 {
118-
// TODO(vuil): support aliases for command-level mapped?
119-
aliases = []string{}
118+
aliases = mapEntry.Aliases
120119
}
121120
if mapEntry.Description != "" {
122121
description = mapEntry.Description

pkg/command/root_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,30 @@ func TestCommandRemapping(t *testing.T) {
18551855
args: []string{"dummy", "arg1", "arg2"},
18561856
expected: []string{"Remap of plugin into command tree (dummy) associated with another plugin is not supported"},
18571857
},
1858+
{
1859+
test: "command-level: subcommand map entry's aliases are used",
1860+
pluginVariants: []fakePluginRemapAttributes{
1861+
{
1862+
name: "dummy",
1863+
target: configtypes.TargetK8s,
1864+
aliases: []string{"dum"},
1865+
},
1866+
{
1867+
name: "dummy2",
1868+
target: configtypes.TargetK8s,
1869+
commandMap: []plugin.CommandMapEntry{
1870+
plugin.CommandMapEntry{
1871+
DestinationCommandPath: "dummy",
1872+
SourceCommandPath: "show-invoke-context",
1873+
Description: "Shows invocation details",
1874+
Aliases: []string{"sic"},
1875+
},
1876+
},
1877+
},
1878+
},
1879+
args: []string{"sic", "arg1", "arg2"},
1880+
expected: []string{"args = (show-invoke-context arg1 arg2), context is ():(dummy):(show-invoke-context)"},
1881+
},
18581882
}
18591883

18601884
for _, spec := range tests {

0 commit comments

Comments
 (0)