diff options
author | a-kenji <aks.kenji@protonmail.com> | 2021-07-22 16:19:46 +0200 |
---|---|---|
committer | a-kenji <aks.kenji@protonmail.com> | 2021-07-22 16:40:36 +0200 |
commit | 903cb68a40979ff3020f431db4a8222eb607e238 (patch) | |
tree | ef9a906587db6ecb358faa579cbdebbc765f46bc /zellij-utils | |
parent | 2bb3c08ae2b0026ee1109857b62db995b0a4474f (diff) |
Add cmd to dump layout to stdout
Adds the ability to dump the default layouts to
stdout, similar to the `zellij setup --dump-config`,
but now it needs the name of a currently existing
layout:
- default
- strider
- disable-status
`zellij setup --dump-layout [LAYOUT]`
Diffstat (limited to 'zellij-utils')
-rw-r--r-- | zellij-utils/src/setup.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index 61c330cdb..aa0bb642b 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -96,13 +96,25 @@ pub const STRIDER_LAYOUT: &[u8] = include_bytes!(concat!( pub const NO_STATUS_LAYOUT: &[u8] = include_bytes!(concat!( env!("CARGO_MANIFEST_DIR"), "/", - "assets/layouts/default.yaml" + "assets/layouts/disable-status-bar.yaml" )); pub fn dump_default_config() -> std::io::Result<()> { dump_asset(DEFAULT_CONFIG) } +pub fn dump_specified_layout(layout: &str) -> std::io::Result<()> { + match layout { + "strider" => dump_asset(STRIDER_LAYOUT), + "default" => dump_asset(DEFAULT_LAYOUT), + "disable-status" => dump_asset(NO_STATUS_LAYOUT), + not_found => Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("Layout: {} not found", not_found), + )), + } +} + #[derive(Debug, Default, Clone, StructOpt, Serialize, Deserialize)] pub struct Setup { /// Dump the default configuration file to stdout @@ -117,6 +129,9 @@ pub struct Setup { #[structopt(long)] pub check: bool, + /// Dump the specified layout file to stdout + #[structopt(long)] + pub dump_layout: Option<String>, /// Generates completion for the specified shell #[structopt(long)] pub generate_completion: Option<String>, @@ -144,6 +159,11 @@ impl Setup { std::process::exit(0); } + if let Some(layout) = &self.dump_layout { + dump_specified_layout(layout)?; + std::process::exit(0); + } + Ok(()) } |