]> git.proxmox.com Git - proxmox-backup.git/commitdiff
src/bin/completion.rs: add echo command
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 2 Dec 2019 10:04:40 +0000 (11:04 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 2 Dec 2019 10:04:40 +0000 (11:04 +0100)
src/bin/completion.rs

index cf9376e1160064b10865c69d9b34110368878e30..5108b4e30ab8f4dc436c9240f4d0756b3386e3d7 100644 (file)
@@ -4,6 +4,26 @@ use proxmox::api::*;
 
 use proxmox_backup::cli::*;
 
+#[api(
+    input: {
+        properties: {
+            text: {
+                type: String,
+                description: "Some text.",
+            }
+        }
+    },
+)]
+/// Echo command. Print the passed text.
+///
+/// Returns: nothing
+fn echo_command(
+    text: String,
+) -> Result<(), Error> {
+    println!("{}", text);
+    Ok(())
+}
+
 #[api(
     input: {
         properties: {
@@ -45,6 +65,8 @@ fn cli_definition() -> CommandLineInterface {
     let cmd_def = CliCommandMap::new()
         .insert("quit", CliCommand::new(&API_METHOD_QUIT_COMMAND).into())
         .insert("hello", CliCommand::new(&API_METHOD_HELLO_COMMAND).into())
+        .insert("echo", CliCommand::new(&API_METHOD_ECHO_COMMAND)
+                .arg_param(&["text"]).into())
         .insert_help();
 
     CommandLineInterface::Nested(cmd_def)