Add --offline cli flag

This commit is contained in:
Joscha 2022-08-27 17:05:40 +02:00
parent 73a0971c34
commit 827a854101
2 changed files with 12 additions and 1 deletions

View file

@ -18,7 +18,7 @@ Procedure when bumping the version number:
- Config file - Config file
- `data_dir` config option - `data_dir` config option
- `ephemeral` config option - `ephemeral` config option
- `offline` config option - `offline` config option and `--offline` cli flag
- `euph.rooms.<name>.autojoin` config option - `euph.rooms.<name>.autojoin` config option
- `euph.rooms.<name>.username` config option - `euph.rooms.<name>.username` config option
- `euph.rooms.<name>.force_username` config option - `euph.rooms.<name>.force_username` config option

View file

@ -72,6 +72,10 @@ struct Args {
#[clap(long, short, action)] #[clap(long, short, action)]
ephemeral: bool, 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 /// Measure the width of characters as displayed by the terminal emulator
/// instead of guessing the width. /// instead of guessing the width.
#[clap(long, short, action)] #[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] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
let args = Args::parse(); let args = Args::parse();
@ -113,6 +123,7 @@ async fn main() -> anyhow::Result<()> {
let mut config = Config::load(&config_path); let mut config = Config::load(&config_path);
set_data_dir(&mut config, args.data_dir); set_data_dir(&mut config, args.data_dir);
set_ephemeral(&mut config, args.ephemeral); set_ephemeral(&mut config, args.ephemeral);
set_offline(&mut config, args.offline);
let config = Box::leak(Box::new(config)); let config = Box::leak(Box::new(config));
let vault = if config.ephemeral { let vault = if config.ephemeral {