summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-07-12 13:31:17 +0300
committerLars Wirzenius <liw@liw.fi>2021-07-12 13:31:17 +0300
commit15c375a0400fcb6de37dde14458b9b2566ae61de (patch)
treed1e48c467537d324f00ceb77e90cac5301149f36 /src/cmd
parent7fa564f500af542771bda7bfada85366a2f47f35 (diff)
downloadvmadm-15c375a0400fcb6de37dde14458b9b2566ae61de.tar.gz
feat: subcommand 'spec'
Sponsored-by: author
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/mod.rs3
-rw-r--r--src/cmd/spec.rs16
2 files changed, 19 insertions, 0 deletions
diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs
index 490cdc4..85ccf4e 100644
--- a/src/cmd/mod.rs
+++ b/src/cmd/mod.rs
@@ -23,3 +23,6 @@ pub use cloud_init::cloud_init;
pub mod config;
pub use config::config;
+
+pub mod spec;
+pub use spec::spec;
diff --git a/src/cmd/spec.rs b/src/cmd/spec.rs
new file mode 100644
index 0000000..b41f234
--- /dev/null
+++ b/src/cmd/spec.rs
@@ -0,0 +1,16 @@
+//! The `spec` sub-command.
+
+use std::io::Write;
+
+use crate::spec::Specification;
+
+/// The `spec` sub-command.
+///
+/// Write the actual VM specifications to stdout.
+pub fn spec(specs: &[Specification]) -> Result<(), std::io::Error> {
+ for spec in specs {
+ let spec = serde_yaml::to_vec(&spec).unwrap();
+ std::io::stdout().write_all(&spec)?;
+ }
+ Ok(())
+}