mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
Using the clippy lint `unwrap_used`, we can automatically lint against all uses of `.unwrap()` on `Result` and `Option`. This turns up quite a few results actually. In most cases, they are invariants that can't actually be hit. For these, we change them to `Option`. In other cases, they can actually be hit. For example, if the user supplies an invalid log-filter. Activating this lint ensures the compiler will yell at us every time we use `.unwrap` to double-check whether we do indeed want to panic here. Resolves: #7292.
41 lines
1008 B
Rust
41 lines
1008 B
Rust
//! CLI subcommands used to test features / dependencies before integrating
|
|
//! them with the GUI, or to exercise features programmatically.
|
|
|
|
use anyhow::Result;
|
|
|
|
#[derive(clap::Subcommand)]
|
|
pub(crate) enum Cmd {
|
|
Replicate6791,
|
|
SetAutostart(SetAutostartArgs),
|
|
}
|
|
|
|
#[derive(clap::Parser)]
|
|
pub(crate) struct SetAutostartArgs {
|
|
#[clap(action=clap::ArgAction::Set)]
|
|
enabled: bool,
|
|
}
|
|
|
|
#[derive(clap::Parser)]
|
|
pub(crate) struct CheckTokenArgs {
|
|
token: String,
|
|
}
|
|
|
|
#[derive(clap::Parser)]
|
|
pub(crate) struct StoreTokenArgs {
|
|
token: String,
|
|
}
|
|
|
|
pub fn run(cmd: Cmd) -> Result<()> {
|
|
match cmd {
|
|
Cmd::Replicate6791 => firezone_gui_client_common::auth::replicate_6791(),
|
|
Cmd::SetAutostart(SetAutostartArgs { enabled }) => set_autostart(enabled),
|
|
}
|
|
}
|
|
|
|
fn set_autostart(enabled: bool) -> Result<()> {
|
|
firezone_headless_client::setup_stdout_logging()?;
|
|
let rt = tokio::runtime::Runtime::new()?;
|
|
rt.block_on(crate::client::gui::set_autostart(enabled))?;
|
|
Ok(())
|
|
}
|