From 827a8541011109766e04a90b23f98dec4fef6aee Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 27 Aug 2022 17:05:40 +0200 Subject: [PATCH] Add --offline cli flag --- CHANGELOG.md | 2 +- src/main.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b02376a..870f0ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Procedure when bumping the version number: - Config file - `data_dir` config option - `ephemeral` config option -- `offline` config option +- `offline` config option and `--offline` cli flag - `euph.rooms..autojoin` config option - `euph.rooms..username` config option - `euph.rooms..force_username` config option diff --git a/src/main.rs b/src/main.rs index 08e471d..ea4610f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,6 +72,10 @@ struct Args { #[clap(long, short, action)] ephemeral: bool, + /// If set, cove will ignore the autojoin config option. + #[clap(long, short, action)] + offline: bool, + /// Measure the width of characters as displayed by the terminal emulator /// instead of guessing the width. #[clap(long, short, action)] @@ -101,6 +105,12 @@ fn set_ephemeral(config: &mut Config, args_ephemeral: bool) { } } +fn set_offline(config: &mut Config, args_offline: bool) { + if args_offline { + config.offline = true; + } +} + #[tokio::main] async fn main() -> anyhow::Result<()> { let args = Args::parse(); @@ -113,6 +123,7 @@ async fn main() -> anyhow::Result<()> { let mut config = Config::load(&config_path); set_data_dir(&mut config, args.data_dir); set_ephemeral(&mut config, args.ephemeral); + set_offline(&mut config, args.offline); let config = Box::leak(Box::new(config)); let vault = if config.ephemeral {