enh: adminSudo: better autocompletion rules

This commit is contained in:
Stéphane Lesimple 2020-11-23 08:35:28 +00:00
parent d1ed88e296
commit e2a64a9d8f
No known key found for this signature in database
GPG key ID: 4B4A3289E9D35658
2 changed files with 10 additions and 1 deletions

View file

@ -3,6 +3,8 @@
"adminSudo" , { "ac" : ["-- --sudo-as"]}, "adminSudo" , { "ac" : ["-- --sudo-as"]},
"adminSudo -- --sudo-as" , { "ac" : ["<ACCOUNT>" ]}, "adminSudo -- --sudo-as" , { "ac" : ["<ACCOUNT>" ]},
"adminSudo -- --sudo-as \\S+" , { "ac" : ["--sudo-cmd" ]}, "adminSudo -- --sudo-as \\S+" , { "ac" : ["--sudo-cmd" ]},
"adminSudo -- --sudo-as \\S+ --sudo-cmd" , { "pr" : ["<PLUGIN> -- <ARG1> <ARG2>" ]} "adminSudo -- --sudo-as \\S+ --sudo-cmd" , { "ac" : ["<COMMAND>" ]},
"adminSudo -- --sudo-as \\S+ --sudo-cmd \\S+" , { "ac" : ["--" ]},
"adminSudo -- --sudo-as \\S+ --sudo-cmd \\S+ --" , { "pr" : ["<enter> or additional COMMAND-specific options" ]}
] ]
} }

View file

@ -149,6 +149,13 @@ EOM
next; next;
} }
} }
elsif ($_ eq '<COMMAND>') {
my $fnret = OVH::Bastion::get_plugin_list();
if ($fnret) {
push @autocomplete, sort keys %{$fnret->value()};
next;
}
}
push @autocomplete, $_; push @autocomplete, $_;
} }
return @autocomplete; return @autocomplete;