ghidra-version-manager 0.7.1

Ghidra Version Manager
use crate::args::default_subcommand::DefaultSubCmd;
use crate::args::prefs_subcommand::PrefsSubCmd;
use crate::args::settings_subcommand::SettingsSubcommand;
use crate::extensions::ExtSubcommand;
use clap::Subcommand;

#[derive(Debug, Subcommand)]
pub enum Cmd {
    /// List the available Ghidra versions
    #[command(alias = "ls")]
    List,

    /// Install a Ghidra version
    #[command(alias = "i")]
    Install {
        /// Which version to install
        tag: String,
    },

    /// Launch Ghidra, unless specified launches the default version
    #[command(alias = "r")]
    Run {
        /// Override the version to run
        tag: Option<String>,
    },

    /// Remove a Ghidra version
    #[command(alias = "del")]
    Uninstall {
        /// The version to remove
        tag: String,
    },

    /// Manage the default version
    Default {
        #[clap(subcommand)]
        cmd: DefaultSubCmd,
    },

    /// Manage preferences
    #[command(alias = "p")]
    Prefs {
        #[clap(subcommand)]
        cmd: PrefsSubCmd,
    },

    /// Update the default version
    #[command(alias = "u")]
    Update,

    /// Force update check
    #[command(alias = "U")]
    CheckUpdate,

    /// Manage extensions
    #[command(alias = "e")]
    Extensions {
        #[clap(subcommand)]
        cmd: ExtSubcommand,
    },

    /// Manage Ghidra settings
    Settings {
        #[clap(subcommand)]
        cmd: SettingsSubcommand,
    },

    /// Get the path to a given Ghidra version
    Locate {
        /// The version to find
        tag: Option<String>,
    },
}

impl Cmd {
    pub fn allow_update_check(&self) -> bool {
        !matches!(
            self,
            Self::Locate { .. } | Self::List | Self::Settings { .. } | Self::Prefs { .. }
        )
    }
}