From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0066C631D3 for ; Wed, 15 Jul 2020 11:41:13 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E3D9E2DF35 for ; Wed, 15 Jul 2020 11:40:43 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C1B302DF2B for ; Wed, 15 Jul 2020 11:40:42 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8E0A04330E for ; Wed, 15 Jul 2020 11:40:42 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 15 Jul 2020 11:40:42 +0200 Message-Id: <20200715094042.21092-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.009 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pbs-devel] [PATCH proxmox-backup] catalog_shell: add exit command X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jul 2020 09:41:14 -0000 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 --- src/backup/catalog_shell.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/backup/catalog_shell.rs b/src/backup/catalog_shell.rs index d59f738..99552cd 100644 --- a/src/backup/catalog_shell.rs +++ b/src/backup/catalog_shell.rs @@ -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) -> Vec 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, -- 2.20.1