wsb 0.124.3689

Workspace - A tool suite for file operations, version management, and development workflow automation
Documentation
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(name = "gitfleet")]
#[command(about = "A Git submodule manager for synchronized superbranches", long_about = None)]
#[command(version)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,

    /// Enable verbose output
    #[arg(short, long, global = true)]
    pub verbose: bool,

    /// Dry run mode (show what would happen without executing)
    #[arg(short = 'n', long, global = true)]
    pub dry_run: bool,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
    /// Show status of all submodules
    Status,

    /// Checkout a branch across all submodules
    Checkout {
        /// Branch name to checkout
        branch: String,

        /// Create the branch if it doesn't exist
        #[arg(short, long)]
        create: bool,
    },

    /// Pull latest changes in all submodules
    Pull {
        /// Use rebase instead of merge
        #[arg(short, long)]
        rebase: bool,
    },

    /// Push changes in all submodules
    Push {
        /// Force push with lease
        #[arg(short, long)]
        force_with_lease: bool,
    },

    /// Create a new branch across all submodules
    Create {
        /// Branch name to create
        branch: String,

        /// Base branch to create from
        #[arg(short, long)]
        from: Option<String>,

        /// Push the new branch immediately
        #[arg(short, long)]
        push: bool,
    },

    /// Commit changes across all submodules
    Commit {
        /// Commit message
        #[arg(short, long)]
        message: String,

        /// Push after committing
        #[arg(short, long)]
        push: bool,
    },

    /// Synchronize all submodules based on .gitmodules
    Sync {
        /// Initialize missing submodules
        #[arg(short, long)]
        init: bool,

        /// Recursive sync for nested submodules
        #[arg(short, long)]
        recursive: bool,
    },

    /// Delete a branch from all submodules
    Delete {
        /// Branch name to delete
        branch: String,

        /// Also delete from remote
        #[arg(short, long)]
        remote: bool,

        /// Force delete
        #[arg(short, long)]
        force: bool,
    },

    /// Fetch updates for all submodules
    Fetch {
        /// Fetch from all remotes
        #[arg(short, long)]
        all: bool,
    },

    /// List branches across all submodules
    Branch {
        /// Show all branches including remotes
        #[arg(short, long)]
        all: bool,
    },

    /// Initialize all submodules
    Init {
        /// Recursively initialize nested submodules
        #[arg(short, long)]
        recursive: bool,
    },

    /// Generate per-file diffs for all submodules and superproject
    Diff {
        /// Base ref to diff against (commit, branch, tag). Without this, diffs unstaged changes.
        #[arg(long)]
        base: Option<String>,

        /// Output directory for diff files
        #[arg(short, long, default_value = "diffs")]
        output: String,

        /// Include staged changes (only when no base ref is given)
        #[arg(short, long)]
        staged: bool,
    },

    /// Stage all changes in all submodules and superproject
    Stage,

    /// Merge current branch back into main across all repos
    MergeBack {
        /// Commit message for staging uncommitted changes before merge
        #[arg(short, long, default_value = "Pre-merge commit")]
        message: String,
    },
}