webapp-rs 0.1.0

A simple CLI tool to create webapps (only support firefox and linux for now.
use clap::{Parser, Subcommand};

use crate::browsers::WebBrowser;

#[derive(Parser)]
#[command(name = "webapp-rs")]
#[command(about = "Create webapps with Firefox", long_about = None)]
#[command(version = "0.1.0")]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Create a new webapp
    Create {
        #[arg(value_enum)]
        browser: WebBrowser,

        #[command(flatten)]
        args: CreateArgs,
    },

    /// Edit an existing webapp
    Edit {
        #[arg(value_enum)]
        browser: WebBrowser,
        /// Codename of the webapp
        codename: String,
        #[command(flatten)]
        args: EditArgs,
    },

    /// List all webapps
    List,

    /// Delete a webapp
    Delete {
        #[arg(value_enum)]
        browser: WebBrowser,
        /// Codename of the webapp
        codename: String,
    },

    /// Run a webapp
    Run {
        /// Codename of the webapp
        codename: String,
    },

    /// Update all webapp profiles
    Update {
        #[arg(value_enum)]
        browser: WebBrowser,
    },
}

#[derive(clap::Args)]
pub struct CreateArgs {
    /// Name of the webapp
    #[arg(long)]
    pub name: String,

    /// URL of the webapp
    #[arg(long)]
    pub url: String,

    /// Icon name (system theme) or path to custom icon
    #[arg(long)]
    pub icon: Option<String>,

    /// Category (Network, Web, Utility, etc.)
    #[arg(long, default_value = "Network")]
    pub category: String,

    /// Use private window for the webapp
    #[arg(long)]
    pub private_window: bool,

    /// Custom Firefox parameters
    #[arg(long)]
    pub custom_params: Option<String>,

    /// Skip uBlock Origin installation
    #[arg(long)]
    pub no_ublock: bool,
}

#[derive(clap::Args)]
pub struct EditArgs {
    /// New name for the webapp
    #[arg(long)]
    pub name: Option<String>,

    /// New URL for the webapp
    #[arg(long)]
    pub url: Option<String>,

    /// New icon for the webapp
    #[arg(long)]
    pub icon: Option<String>,

    /// Use private window for the webapp
    #[arg(long)]
    pub private_window: Option<bool>,
}