changeset 10:188bf8ab3e81

fmt
author AnaTofuZ <anatofuz@gmail.com>
date Wed, 28 Oct 2020 18:21:54 +0900
parents b89466455757
children 9fac2c578228
files src/main.rs
diffstat 1 files changed, 48 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.rs	Wed Oct 28 17:35:12 2020 +0900
+++ b/src/main.rs	Wed Oct 28 18:21:54 2020 +0900
@@ -11,9 +11,14 @@
 
 #[derive(Clap)]
 enum SubCommand {
-    define(Define),
-    shutdown(Shutdown),
-    list(List),
+    List(List),
+    Undefine(UnDefine),
+    Define(Define),
+    Shutdown(Shutdown),
+    Destroy(Destroy),
+    Console(Console),
+    Start(Start),
+    Ttyconsole(TTyConsole),
 }
 
 /// define (but don't start) a domain from an template XML file
@@ -22,6 +27,24 @@
     name: String,
 }
 
+/// undefine a domain
+#[derive(Clap)]
+struct UnDefine {
+    name: String,
+}
+
+/// start a (previously defined) inactive domain
+#[derive(Clap)]
+struct Start {
+    name: String,
+}
+
+/// tty console
+#[derive(Clap)]
+struct TTyConsole {
+    name_or_id: String,
+}
+
 /// gracefully shutdown a domain
 #[derive(Clap)]
 struct Shutdown {
@@ -32,7 +55,19 @@
 #[derive(Clap)]
 struct List {}
 
-struct list_dump_msg {
+/// destroy (stop) a domain
+#[derive(Clap)]
+struct Destroy {
+    name: String,
+}
+
+/// connect to the guest console
+#[derive(Clap)]
+struct Console {
+    name_or_id: String,
+}
+
+struct ListDumpMsg {
     info_msg: String,
     border_line: String,
 }
@@ -52,10 +87,7 @@
     println!("uid: {} gid: {} name: {}", uid, gid, user_name);
 
     match opts.subcmd {
-        SubCommand::define(name) => {}
-        SubCommand::shutdown(name) => {}
-
-        SubCommand::list(list) => {
+        SubCommand::List(_) => {
             set_root_id();
             let (ldump_msg, vm_list_strs) = list_command(user_name);
             println!("{}\n{}", ldump_msg.info_msg, ldump_msg.border_line);
@@ -63,6 +95,12 @@
                 println!("{}", vm_info);
             }
         }
+        SubCommand::Define(name) => {}
+        SubCommand::Shutdown(name) => {}
+        SubCommand::Console(name) => {}
+
+        SubCommand::Destroy(name_or_id) => {}
+        _ => {}
     }
 
     //set_root_id();
@@ -86,7 +124,7 @@
     return gid_struct.into();
 }
 
-fn list_command(user_name: &'static str) -> (list_dump_msg, Vec<String>) {
+fn list_command(user_name: &'static str) -> (ListDumpMsg, Vec<String>) {
     let output = Command::new("virsh")
         .arg("list")
         .arg("--all")
@@ -97,7 +135,7 @@
 
     let info_msg = virsh_list.next().unwrap();
     let border_line = virsh_list.next().unwrap();
-    let ldump_msg = list_dump_msg {
+    let ldump_msg = ListDumpMsg {
         info_msg: String::from(info_msg),
         border_line: String::from(border_line),
     };