public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH proxmox-backup] catalog_shell: add exit command
Date: Wed, 15 Jul 2020 12:21:17 +0200	[thread overview]
Message-ID: <20200715102117.ordmd7e5wgfvkbln@olga.proxmox.com> (raw)
In-Reply-To: <20200715094042.21092-1-d.csapak@proxmox.com>

applied

On Wed, Jul 15, 2020 at 11:40:42AM +0200, Dominik Csapak wrote:
> 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>
> ---
>  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<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,
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




      reply	other threads:[~2020-07-15 10:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15  9:40 [pbs-devel] " Dominik Csapak
2020-07-15 10:21 ` Wolfgang Bumiller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200715102117.ordmd7e5wgfvkbln@olga.proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal