catalog_shell: add exit command
it is nice to have a command to exit from the shell instead of only allowing ctrl+d or ctrl+c the api method is just for documentation/help purposes and does nothing by itself, the real logic is directly in the read loop Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
b25deec0be
commit
ac5e9e770b
@ -89,6 +89,10 @@ pub fn catalog_shell_cli() -> CommandLineInterface {
|
||||
"find",
|
||||
CliCommand::new(&API_METHOD_FIND_COMMAND).arg_param(&["pattern"]),
|
||||
)
|
||||
.insert(
|
||||
"exit",
|
||||
CliCommand::new(&API_METHOD_EXIT),
|
||||
)
|
||||
.insert_help(),
|
||||
)
|
||||
}
|
||||
@ -104,6 +108,14 @@ fn complete_path(complete_me: &str, _map: &HashMap<String, String>) -> Vec<Strin
|
||||
}
|
||||
}
|
||||
|
||||
// just an empty wrapper so that it is displayed in help/docs, we check
|
||||
// in the readloop for 'exit' again break
|
||||
#[api(input: { properties: {} })]
|
||||
/// Exit the shell
|
||||
async fn exit() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(input: { properties: {} })]
|
||||
/// List the current working directory.
|
||||
async fn pwd_command() -> Result<(), Error> {
|
||||
@ -439,6 +451,9 @@ impl Shell {
|
||||
SHELL = Some(this as *mut Shell as usize);
|
||||
}
|
||||
while let Ok(line) = this.rl.readline(&this.prompt) {
|
||||
if line == "exit" {
|
||||
break;
|
||||
}
|
||||
let helper = this.rl.helper().unwrap();
|
||||
let args = match cli::shellword_split(&line) {
|
||||
Ok(args) => args,
|
||||
|
Loading…
Reference in New Issue
Block a user