pub(crate) mod bridge;
pub(crate) mod harvest;
pub(crate) mod request;
use std::path::Path;
use anyhow::Result;
use clap::{Parser, Subcommand};
use crate::browser::auth;
pub(crate) fn resolve_client_token(token_file: Option<&Path>) -> Result<String> {
match auth::resolve_existing_token(token_file) {
Ok(token) => Ok(token),
Err(e) => {
if token_file.is_none() {
if let Ok(path) = crate::daemon::paths::token_path() {
if path.exists() {
return auth::resolve_existing_token(Some(&path));
}
}
}
Err(e)
}
}
}
#[derive(Parser)]
pub struct BrowserCommand {
#[command(subcommand)]
pub command: BrowserSubcommands,
}
#[derive(Subcommand)]
pub enum BrowserSubcommands {
Bridge(bridge::BridgeCommand),
}
impl BrowserCommand {
pub async fn execute(self) -> Result<()> {
match self.command {
BrowserSubcommands::Bridge(cmd) => cmd.execute().await,
}
}
}