forked from mirrors/jj
cli: rename *Commands
enums to *Command
Each instance of the enum represents a single command, so singular `*Command` seems better. That also seems to match the examples in clap's documentation.
This commit is contained in:
parent
4aad7f86ac
commit
a0cbe7ced0
10 changed files with 112 additions and 115 deletions
|
@ -31,7 +31,7 @@ use jj_lib::signing::Signer;
|
|||
use jj_lib::workspace::{Workspace, WorkspaceInitError};
|
||||
|
||||
#[derive(clap::Parser, Clone, Debug)]
|
||||
enum CustomCommands {
|
||||
enum CustomCommand {
|
||||
/// Initialize a workspace using the Jit backend
|
||||
InitJit,
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ fn create_store_factories() -> StoreFactories {
|
|||
fn run_custom_command(
|
||||
_ui: &mut Ui,
|
||||
command_helper: &CommandHelper,
|
||||
command: CustomCommands,
|
||||
command: CustomCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match command {
|
||||
CustomCommands::InitJit => {
|
||||
CustomCommand::InitJit => {
|
||||
let wc_path = command_helper.cwd();
|
||||
// Initialize a workspace with the custom backend
|
||||
Workspace::init_with_backend(
|
||||
|
|
|
@ -18,7 +18,7 @@ use jj_cli::cli_util::{CliRunner, CommandError, CommandHelper};
|
|||
use jj_cli::ui::Ui;
|
||||
|
||||
#[derive(clap::Parser, Clone, Debug)]
|
||||
enum CustomCommands {
|
||||
enum CustomCommand {
|
||||
Frobnicate(FrobnicateArgs),
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,10 @@ struct FrobnicateArgs {
|
|||
fn run_custom_command(
|
||||
ui: &mut Ui,
|
||||
command_helper: &CommandHelper,
|
||||
command: CustomCommands,
|
||||
command: CustomCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match command {
|
||||
CustomCommands::Frobnicate(args) => {
|
||||
CustomCommand::Frobnicate(args) => {
|
||||
let mut workspace_command = command_helper.workspace_helper(ui)?;
|
||||
let commit = workspace_command.resolve_single_rev(&args.revision, ui)?;
|
||||
let mut tx = workspace_command.start_transaction("Frobnicate");
|
||||
|
|
|
@ -39,7 +39,7 @@ use jj_lib::workspace::{
|
|||
};
|
||||
|
||||
#[derive(clap::Parser, Clone, Debug)]
|
||||
enum CustomCommands {
|
||||
enum CustomCommand {
|
||||
/// Initialize a workspace using the "conflicts" working copy
|
||||
InitConflicts,
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ enum CustomCommands {
|
|||
fn run_custom_command(
|
||||
_ui: &mut Ui,
|
||||
command_helper: &CommandHelper,
|
||||
command: CustomCommands,
|
||||
command: CustomCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match command {
|
||||
CustomCommands::InitConflicts => {
|
||||
CustomCommand::InitConflicts => {
|
||||
let wc_path = command_helper.cwd();
|
||||
let backend_initializer = |settings: &UserSettings, store_path: &Path| {
|
||||
let backend: Box<dyn Backend> =
|
||||
|
|
|
@ -29,7 +29,7 @@ use crate::ui::Ui;
|
|||
/// Commands for benchmarking internal operations
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
#[command(hide = true)]
|
||||
pub enum BenchCommands {
|
||||
pub enum BenchCommand {
|
||||
#[command(name = "commonancestors")]
|
||||
CommonAncestors(BenchCommonAncestorsArgs),
|
||||
#[command(name = "isancestor")]
|
||||
|
@ -127,10 +127,10 @@ where
|
|||
pub(crate) fn cmd_bench(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &BenchCommands,
|
||||
subcommand: &BenchCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
BenchCommands::CommonAncestors(args) => {
|
||||
BenchCommand::CommonAncestors(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let commit1 = workspace_command.resolve_single_rev(&args.revision1, ui)?;
|
||||
let commit2 = workspace_command.resolve_single_rev(&args.revision2, ui)?;
|
||||
|
@ -144,7 +144,7 @@ pub(crate) fn cmd_bench(
|
|||
routine,
|
||||
)?;
|
||||
}
|
||||
BenchCommands::IsAncestor(args) => {
|
||||
BenchCommand::IsAncestor(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let ancestor_commit = workspace_command.resolve_single_rev(&args.ancestor, ui)?;
|
||||
let descendant_commit = workspace_command.resolve_single_rev(&args.descendant, ui)?;
|
||||
|
@ -157,7 +157,7 @@ pub(crate) fn cmd_bench(
|
|||
routine,
|
||||
)?;
|
||||
}
|
||||
BenchCommands::ResolvePrefix(args) => {
|
||||
BenchCommand::ResolvePrefix(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let prefix = HexPrefix::new(&args.prefix).unwrap();
|
||||
let index = workspace_command.repo().index();
|
||||
|
@ -169,7 +169,7 @@ pub(crate) fn cmd_bench(
|
|||
routine,
|
||||
)?;
|
||||
}
|
||||
BenchCommands::Revset(args) => {
|
||||
BenchCommand::Revset(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let revsets = if let Some(file_path) = &args.file {
|
||||
std::fs::read_to_string(command.cwd().join(file_path))?
|
||||
|
|
|
@ -30,7 +30,7 @@ use crate::ui::Ui;
|
|||
/// Low-level commands not intended for users
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
#[command(hide = true)]
|
||||
pub enum DebugCommands {
|
||||
pub enum DebugCommand {
|
||||
Revset(DebugRevsetArgs),
|
||||
#[command(name = "workingcopy")]
|
||||
WorkingCopy(DebugWorkingCopyArgs),
|
||||
|
@ -109,11 +109,11 @@ pub enum DebugWatchmanSubcommand {
|
|||
pub fn cmd_debug(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &DebugCommands,
|
||||
subcommand: &DebugCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
DebugCommands::Revset(args) => cmd_debug_revset(ui, command, args)?,
|
||||
DebugCommands::WorkingCopy(_wc_args) => {
|
||||
DebugCommand::Revset(args) => cmd_debug_revset(ui, command, args)?,
|
||||
DebugCommand::WorkingCopy(_wc_args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let wc = check_local_disk_wc(workspace_command.working_copy().as_any())?;
|
||||
writeln!(ui.stdout(), "Current operation: {:?}", wc.operation_id())?;
|
||||
|
@ -129,11 +129,11 @@ pub fn cmd_debug(
|
|||
)?;
|
||||
}
|
||||
}
|
||||
DebugCommands::Template(template_args) => {
|
||||
DebugCommand::Template(template_args) => {
|
||||
let node = template_parser::parse_template(&template_args.template)?;
|
||||
writeln!(ui.stdout(), "{node:#?}")?;
|
||||
}
|
||||
DebugCommands::Index(_index_args) => {
|
||||
DebugCommand::Index(_index_args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let repo = workspace_command.repo();
|
||||
let index_impl: Option<&ReadonlyIndexWrapper> =
|
||||
|
@ -162,7 +162,7 @@ pub fn cmd_debug(
|
|||
)));
|
||||
}
|
||||
}
|
||||
DebugCommands::ReIndex(_reindex_args) => {
|
||||
DebugCommand::ReIndex(_reindex_args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let repo = workspace_command.repo();
|
||||
let default_index_store: Option<&DefaultIndexStore> =
|
||||
|
@ -187,7 +187,7 @@ pub fn cmd_debug(
|
|||
)));
|
||||
}
|
||||
}
|
||||
DebugCommands::Operation(operation_args) => {
|
||||
DebugCommand::Operation(operation_args) => {
|
||||
// Resolve the operation without loading the repo, so this command can be used
|
||||
// even if e.g. the view object is broken.
|
||||
let workspace = command.load_workspace()?;
|
||||
|
@ -208,8 +208,8 @@ pub fn cmd_debug(
|
|||
writeln!(ui.stdout(), "{:#?}", op.view()?.store_view())?;
|
||||
}
|
||||
}
|
||||
DebugCommands::Tree(sub_args) => cmd_debug_tree(ui, command, sub_args)?,
|
||||
DebugCommands::Watchman(watchman_subcommand) => {
|
||||
DebugCommand::Tree(sub_args) => cmd_debug_tree(ui, command, sub_args)?,
|
||||
DebugCommand::Watchman(watchman_subcommand) => {
|
||||
cmd_debug_watchman(ui, command, watchman_subcommand)?;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,23 +41,23 @@ use crate::ui::Ui;
|
|||
/// For a comparison with Git, including a table of commands, see
|
||||
/// https://github.com/martinvonz/jj/blob/main/docs/git-comparison.md.
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
pub enum GitCommands {
|
||||
pub enum GitCommand {
|
||||
#[command(subcommand)]
|
||||
Remote(GitRemoteCommands),
|
||||
Remote(GitRemoteCommand),
|
||||
Fetch(GitFetchArgs),
|
||||
Clone(GitCloneArgs),
|
||||
Push(GitPushArgs),
|
||||
Import(GitImportArgs),
|
||||
Export(GitExportArgs),
|
||||
#[command(subcommand, hide = true)]
|
||||
Submodule(GitSubmoduleCommands),
|
||||
Submodule(GitSubmoduleCommand),
|
||||
}
|
||||
|
||||
/// Manage Git remotes
|
||||
///
|
||||
/// The Git repo will be a bare git repo stored inside the `.jj/` directory.
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
pub enum GitRemoteCommands {
|
||||
pub enum GitRemoteCommand {
|
||||
Add(GitRemoteAddArgs),
|
||||
Remove(GitRemoteRemoveArgs),
|
||||
Rename(GitRemoteRenameArgs),
|
||||
|
@ -175,7 +175,7 @@ pub struct GitExportArgs {}
|
|||
|
||||
/// FOR INTERNAL USE ONLY Interact with git submodules
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
pub enum GitSubmoduleCommands {
|
||||
pub enum GitSubmoduleCommand {
|
||||
/// Print the relevant contents from .gitmodules. For debugging purposes
|
||||
/// only.
|
||||
PrintGitmodules(GitSubmodulePrintGitmodulesArgs),
|
||||
|
@ -1147,25 +1147,23 @@ fn cmd_git_submodule_print_gitmodules(
|
|||
pub fn cmd_git(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &GitCommands,
|
||||
subcommand: &GitCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
GitCommands::Fetch(args) => cmd_git_fetch(ui, command, args),
|
||||
GitCommands::Clone(args) => cmd_git_clone(ui, command, args),
|
||||
GitCommands::Remote(GitRemoteCommands::Add(args)) => cmd_git_remote_add(ui, command, args),
|
||||
GitCommands::Remote(GitRemoteCommands::Remove(args)) => {
|
||||
GitCommand::Fetch(args) => cmd_git_fetch(ui, command, args),
|
||||
GitCommand::Clone(args) => cmd_git_clone(ui, command, args),
|
||||
GitCommand::Remote(GitRemoteCommand::Add(args)) => cmd_git_remote_add(ui, command, args),
|
||||
GitCommand::Remote(GitRemoteCommand::Remove(args)) => {
|
||||
cmd_git_remote_remove(ui, command, args)
|
||||
}
|
||||
GitCommands::Remote(GitRemoteCommands::Rename(args)) => {
|
||||
GitCommand::Remote(GitRemoteCommand::Rename(args)) => {
|
||||
cmd_git_remote_rename(ui, command, args)
|
||||
}
|
||||
GitCommands::Remote(GitRemoteCommands::List(args)) => {
|
||||
cmd_git_remote_list(ui, command, args)
|
||||
}
|
||||
GitCommands::Push(args) => cmd_git_push(ui, command, args),
|
||||
GitCommands::Import(args) => cmd_git_import(ui, command, args),
|
||||
GitCommands::Export(args) => cmd_git_export(ui, command, args),
|
||||
GitCommands::Submodule(GitSubmoduleCommands::PrintGitmodules(args)) => {
|
||||
GitCommand::Remote(GitRemoteCommand::List(args)) => cmd_git_remote_list(ui, command, args),
|
||||
GitCommand::Push(args) => cmd_git_push(ui, command, args),
|
||||
GitCommand::Import(args) => cmd_git_import(ui, command, args),
|
||||
GitCommand::Export(args) => cmd_git_export(ui, command, args),
|
||||
GitCommand::Submodule(GitSubmoduleCommand::PrintGitmodules(args)) => {
|
||||
cmd_git_submodule_print_gitmodules(ui, command, args)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,19 +57,19 @@ mod workspace;
|
|||
|
||||
use std::fmt::Debug;
|
||||
|
||||
use clap::{Command, CommandFactory, FromArgMatches, Subcommand};
|
||||
use clap::{CommandFactory, FromArgMatches, Subcommand};
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::cli_util::{user_error_with_hint, Args, CommandError, CommandHelper};
|
||||
use crate::ui::Ui;
|
||||
|
||||
#[derive(clap::Parser, Clone, Debug)]
|
||||
enum Commands {
|
||||
enum Command {
|
||||
Abandon(abandon::AbandonArgs),
|
||||
Backout(backout::BackoutArgs),
|
||||
#[cfg(feature = "bench")]
|
||||
#[command(subcommand)]
|
||||
Bench(bench::BenchCommands),
|
||||
Bench(bench::BenchCommand),
|
||||
#[command(subcommand)]
|
||||
Branch(branch::BranchSubcommand),
|
||||
#[command(alias = "print")]
|
||||
|
@ -80,7 +80,7 @@ enum Commands {
|
|||
#[command(subcommand)]
|
||||
Config(config::ConfigSubcommand),
|
||||
#[command(subcommand)]
|
||||
Debug(debug::DebugCommands),
|
||||
Debug(debug::DebugCommand),
|
||||
Describe(describe::DescribeArgs),
|
||||
Diff(diff::DiffArgs),
|
||||
Diffedit(diffedit::DiffeditArgs),
|
||||
|
@ -88,7 +88,7 @@ enum Commands {
|
|||
Edit(edit::EditArgs),
|
||||
Files(files::FilesArgs),
|
||||
#[command(subcommand)]
|
||||
Git(git::GitCommands),
|
||||
Git(git::GitCommand),
|
||||
Init(init::InitArgs),
|
||||
Interdiff(interdiff::InterdiffArgs),
|
||||
Log(log::LogArgs),
|
||||
|
@ -108,7 +108,7 @@ enum Commands {
|
|||
Obslog(obslog::ObslogArgs),
|
||||
#[command(subcommand)]
|
||||
#[command(visible_alias = "op")]
|
||||
Operation(operation::OperationCommands),
|
||||
Operation(operation::OperationCommand),
|
||||
Prev(prev::PrevArgs),
|
||||
Rebase(rebase::RebaseArgs),
|
||||
Resolve(resolve::ResolveArgs),
|
||||
|
@ -128,14 +128,14 @@ enum Commands {
|
|||
Squash(squash::SquashArgs),
|
||||
Status(status::StatusArgs),
|
||||
#[command(subcommand)]
|
||||
Util(util::UtilCommands),
|
||||
Util(util::UtilCommand),
|
||||
/// Undo an operation (shortcut for `jj op undo`)
|
||||
Undo(operation::OperationUndoArgs),
|
||||
Unsquash(unsquash::UnsquashArgs),
|
||||
Untrack(untrack::UntrackArgs),
|
||||
Version(version::VersionArgs),
|
||||
#[command(subcommand)]
|
||||
Workspace(workspace::WorkspaceCommands),
|
||||
Workspace(workspace::WorkspaceCommand),
|
||||
}
|
||||
|
||||
/// A dummy command that accepts any arguments
|
||||
|
@ -145,59 +145,58 @@ struct DummyCommandArgs {
|
|||
_args: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn default_app() -> Command {
|
||||
Commands::augment_subcommands(Args::command())
|
||||
pub fn default_app() -> clap::Command {
|
||||
Command::augment_subcommands(Args::command())
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), CommandError> {
|
||||
let derived_subcommands: Commands =
|
||||
Commands::from_arg_matches(command_helper.matches()).unwrap();
|
||||
let derived_subcommands: Command = Command::from_arg_matches(command_helper.matches()).unwrap();
|
||||
match &derived_subcommands {
|
||||
Commands::Version(sub_args) => version::cmd_version(ui, command_helper, sub_args),
|
||||
Commands::Init(sub_args) => init::cmd_init(ui, command_helper, sub_args),
|
||||
Commands::Config(sub_args) => config::cmd_config(ui, command_helper, sub_args),
|
||||
Commands::Checkout(sub_args) => checkout::cmd_checkout(ui, command_helper, sub_args),
|
||||
Commands::Untrack(sub_args) => untrack::cmd_untrack(ui, command_helper, sub_args),
|
||||
Commands::Files(sub_args) => files::cmd_files(ui, command_helper, sub_args),
|
||||
Commands::Cat(sub_args) => cat::cmd_cat(ui, command_helper, sub_args),
|
||||
Commands::Diff(sub_args) => diff::cmd_diff(ui, command_helper, sub_args),
|
||||
Commands::Show(sub_args) => show::cmd_show(ui, command_helper, sub_args),
|
||||
Commands::Status(sub_args) => status::cmd_status(ui, command_helper, sub_args),
|
||||
Commands::Log(sub_args) => log::cmd_log(ui, command_helper, sub_args),
|
||||
Commands::Interdiff(sub_args) => interdiff::cmd_interdiff(ui, command_helper, sub_args),
|
||||
Commands::Obslog(sub_args) => obslog::cmd_obslog(ui, command_helper, sub_args),
|
||||
Commands::Describe(sub_args) => describe::cmd_describe(ui, command_helper, sub_args),
|
||||
Commands::Commit(sub_args) => commit::cmd_commit(ui, command_helper, sub_args),
|
||||
Commands::Duplicate(sub_args) => duplicate::cmd_duplicate(ui, command_helper, sub_args),
|
||||
Commands::Abandon(sub_args) => abandon::cmd_abandon(ui, command_helper, sub_args),
|
||||
Commands::Edit(sub_args) => edit::cmd_edit(ui, command_helper, sub_args),
|
||||
Commands::Next(sub_args) => next::cmd_next(ui, command_helper, sub_args),
|
||||
Commands::Prev(sub_args) => prev::cmd_prev(ui, command_helper, sub_args),
|
||||
Commands::New(sub_args) => new::cmd_new(ui, command_helper, sub_args),
|
||||
Commands::Move(sub_args) => r#move::cmd_move(ui, command_helper, sub_args),
|
||||
Commands::Squash(sub_args) => squash::cmd_squash(ui, command_helper, sub_args),
|
||||
Commands::Unsquash(sub_args) => unsquash::cmd_unsquash(ui, command_helper, sub_args),
|
||||
Commands::Restore(sub_args) => restore::cmd_restore(ui, command_helper, sub_args),
|
||||
Commands::Revert(_args) => revert(),
|
||||
Commands::Run(sub_args) => run::cmd_run(ui, command_helper, sub_args),
|
||||
Commands::Diffedit(sub_args) => diffedit::cmd_diffedit(ui, command_helper, sub_args),
|
||||
Commands::Split(sub_args) => split::cmd_split(ui, command_helper, sub_args),
|
||||
Commands::Merge(sub_args) => merge::cmd_merge(ui, command_helper, sub_args),
|
||||
Commands::Rebase(sub_args) => rebase::cmd_rebase(ui, command_helper, sub_args),
|
||||
Commands::Backout(sub_args) => backout::cmd_backout(ui, command_helper, sub_args),
|
||||
Commands::Resolve(sub_args) => resolve::cmd_resolve(ui, command_helper, sub_args),
|
||||
Commands::Branch(sub_args) => branch::cmd_branch(ui, command_helper, sub_args),
|
||||
Commands::Undo(sub_args) => operation::cmd_op_undo(ui, command_helper, sub_args),
|
||||
Commands::Operation(sub_args) => operation::cmd_operation(ui, command_helper, sub_args),
|
||||
Commands::Workspace(sub_args) => workspace::cmd_workspace(ui, command_helper, sub_args),
|
||||
Commands::Sparse(sub_args) => sparse::cmd_sparse(ui, command_helper, sub_args),
|
||||
Commands::Chmod(sub_args) => chmod::cmd_chmod(ui, command_helper, sub_args),
|
||||
Commands::Git(sub_args) => git::cmd_git(ui, command_helper, sub_args),
|
||||
Commands::Util(sub_args) => util::cmd_util(ui, command_helper, sub_args),
|
||||
Command::Version(sub_args) => version::cmd_version(ui, command_helper, sub_args),
|
||||
Command::Init(sub_args) => init::cmd_init(ui, command_helper, sub_args),
|
||||
Command::Config(sub_args) => config::cmd_config(ui, command_helper, sub_args),
|
||||
Command::Checkout(sub_args) => checkout::cmd_checkout(ui, command_helper, sub_args),
|
||||
Command::Untrack(sub_args) => untrack::cmd_untrack(ui, command_helper, sub_args),
|
||||
Command::Files(sub_args) => files::cmd_files(ui, command_helper, sub_args),
|
||||
Command::Cat(sub_args) => cat::cmd_cat(ui, command_helper, sub_args),
|
||||
Command::Diff(sub_args) => diff::cmd_diff(ui, command_helper, sub_args),
|
||||
Command::Show(sub_args) => show::cmd_show(ui, command_helper, sub_args),
|
||||
Command::Status(sub_args) => status::cmd_status(ui, command_helper, sub_args),
|
||||
Command::Log(sub_args) => log::cmd_log(ui, command_helper, sub_args),
|
||||
Command::Interdiff(sub_args) => interdiff::cmd_interdiff(ui, command_helper, sub_args),
|
||||
Command::Obslog(sub_args) => obslog::cmd_obslog(ui, command_helper, sub_args),
|
||||
Command::Describe(sub_args) => describe::cmd_describe(ui, command_helper, sub_args),
|
||||
Command::Commit(sub_args) => commit::cmd_commit(ui, command_helper, sub_args),
|
||||
Command::Duplicate(sub_args) => duplicate::cmd_duplicate(ui, command_helper, sub_args),
|
||||
Command::Abandon(sub_args) => abandon::cmd_abandon(ui, command_helper, sub_args),
|
||||
Command::Edit(sub_args) => edit::cmd_edit(ui, command_helper, sub_args),
|
||||
Command::Next(sub_args) => next::cmd_next(ui, command_helper, sub_args),
|
||||
Command::Prev(sub_args) => prev::cmd_prev(ui, command_helper, sub_args),
|
||||
Command::New(sub_args) => new::cmd_new(ui, command_helper, sub_args),
|
||||
Command::Move(sub_args) => r#move::cmd_move(ui, command_helper, sub_args),
|
||||
Command::Squash(sub_args) => squash::cmd_squash(ui, command_helper, sub_args),
|
||||
Command::Unsquash(sub_args) => unsquash::cmd_unsquash(ui, command_helper, sub_args),
|
||||
Command::Restore(sub_args) => restore::cmd_restore(ui, command_helper, sub_args),
|
||||
Command::Revert(_args) => revert(),
|
||||
Command::Run(sub_args) => run::cmd_run(ui, command_helper, sub_args),
|
||||
Command::Diffedit(sub_args) => diffedit::cmd_diffedit(ui, command_helper, sub_args),
|
||||
Command::Split(sub_args) => split::cmd_split(ui, command_helper, sub_args),
|
||||
Command::Merge(sub_args) => merge::cmd_merge(ui, command_helper, sub_args),
|
||||
Command::Rebase(sub_args) => rebase::cmd_rebase(ui, command_helper, sub_args),
|
||||
Command::Backout(sub_args) => backout::cmd_backout(ui, command_helper, sub_args),
|
||||
Command::Resolve(sub_args) => resolve::cmd_resolve(ui, command_helper, sub_args),
|
||||
Command::Branch(sub_args) => branch::cmd_branch(ui, command_helper, sub_args),
|
||||
Command::Undo(sub_args) => operation::cmd_op_undo(ui, command_helper, sub_args),
|
||||
Command::Operation(sub_args) => operation::cmd_operation(ui, command_helper, sub_args),
|
||||
Command::Workspace(sub_args) => workspace::cmd_workspace(ui, command_helper, sub_args),
|
||||
Command::Sparse(sub_args) => sparse::cmd_sparse(ui, command_helper, sub_args),
|
||||
Command::Chmod(sub_args) => chmod::cmd_chmod(ui, command_helper, sub_args),
|
||||
Command::Git(sub_args) => git::cmd_git(ui, command_helper, sub_args),
|
||||
Command::Util(sub_args) => util::cmd_util(ui, command_helper, sub_args),
|
||||
#[cfg(feature = "bench")]
|
||||
Commands::Bench(sub_args) => bench::cmd_bench(ui, command_helper, sub_args),
|
||||
Commands::Debug(sub_args) => debug::cmd_debug(ui, command_helper, sub_args),
|
||||
Command::Bench(sub_args) => bench::cmd_bench(ui, command_helper, sub_args),
|
||||
Command::Debug(sub_args) => debug::cmd_debug(ui, command_helper, sub_args),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::ui::Ui;
|
|||
/// For information about the operation log, see
|
||||
/// https://github.com/martinvonz/jj/blob/main/docs/operation-log.md.
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
pub enum OperationCommands {
|
||||
pub enum OperationCommand {
|
||||
Log(OperationLogArgs),
|
||||
Undo(OperationUndoArgs),
|
||||
Restore(OperationRestoreArgs),
|
||||
|
@ -240,11 +240,11 @@ fn cmd_op_restore(
|
|||
pub fn cmd_operation(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &OperationCommands,
|
||||
subcommand: &OperationCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
OperationCommands::Log(args) => cmd_op_log(ui, command, args),
|
||||
OperationCommands::Restore(args) => cmd_op_restore(ui, command, args),
|
||||
OperationCommands::Undo(args) => cmd_op_undo(ui, command, args),
|
||||
OperationCommand::Log(args) => cmd_op_log(ui, command, args),
|
||||
OperationCommand::Restore(args) => cmd_op_restore(ui, command, args),
|
||||
OperationCommand::Undo(args) => cmd_op_undo(ui, command, args),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::ui::Ui;
|
|||
|
||||
/// Infrequently used commands such as for generating shell completions
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
pub(crate) enum UtilCommands {
|
||||
pub(crate) enum UtilCommand {
|
||||
Completion(UtilCompletionArgs),
|
||||
Mangen(UtilMangenArgs),
|
||||
ConfigSchema(UtilConfigSchemaArgs),
|
||||
|
@ -68,10 +68,10 @@ pub(crate) struct UtilConfigSchemaArgs {}
|
|||
pub(crate) fn cmd_util(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &UtilCommands,
|
||||
subcommand: &UtilCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
UtilCommands::Completion(completion_args) => {
|
||||
UtilCommand::Completion(completion_args) => {
|
||||
let mut app = command.app().clone();
|
||||
let mut buf = vec![];
|
||||
let shell = if completion_args.zsh {
|
||||
|
@ -84,13 +84,13 @@ pub(crate) fn cmd_util(
|
|||
clap_complete::generate(shell, &mut app, "jj", &mut buf);
|
||||
ui.stdout_formatter().write_all(&buf)?;
|
||||
}
|
||||
UtilCommands::Mangen(_mangen_args) => {
|
||||
UtilCommand::Mangen(_mangen_args) => {
|
||||
let mut buf = vec![];
|
||||
let man = clap_mangen::Man::new(command.app().clone());
|
||||
man.render(&mut buf)?;
|
||||
ui.stdout_formatter().write_all(&buf)?;
|
||||
}
|
||||
UtilCommands::ConfigSchema(_config_schema_args) => {
|
||||
UtilCommand::ConfigSchema(_config_schema_args) => {
|
||||
// TODO(#879): Consider generating entire schema dynamically vs. static file.
|
||||
let buf = include_bytes!("../config-schema.json");
|
||||
ui.stdout_formatter().write_all(buf)?;
|
||||
|
|
|
@ -42,7 +42,7 @@ use crate::ui::Ui;
|
|||
/// workspace attached to a repo, they are indicated by `@<workspace name>` in
|
||||
/// `jj log`.
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
pub(crate) enum WorkspaceCommands {
|
||||
pub(crate) enum WorkspaceCommand {
|
||||
Add(WorkspaceAddArgs),
|
||||
Forget(WorkspaceForgetArgs),
|
||||
List(WorkspaceListArgs),
|
||||
|
@ -107,14 +107,14 @@ pub(crate) struct WorkspaceUpdateStaleArgs {}
|
|||
pub(crate) fn cmd_workspace(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &WorkspaceCommands,
|
||||
subcommand: &WorkspaceCommand,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
WorkspaceCommands::Add(args) => cmd_workspace_add(ui, command, args),
|
||||
WorkspaceCommands::Forget(args) => cmd_workspace_forget(ui, command, args),
|
||||
WorkspaceCommands::List(args) => cmd_workspace_list(ui, command, args),
|
||||
WorkspaceCommands::Root(args) => cmd_workspace_root(ui, command, args),
|
||||
WorkspaceCommands::UpdateStale(args) => cmd_workspace_update_stale(ui, command, args),
|
||||
WorkspaceCommand::Add(args) => cmd_workspace_add(ui, command, args),
|
||||
WorkspaceCommand::Forget(args) => cmd_workspace_forget(ui, command, args),
|
||||
WorkspaceCommand::List(args) => cmd_workspace_list(ui, command, args),
|
||||
WorkspaceCommand::Root(args) => cmd_workspace_root(ui, command, args),
|
||||
WorkspaceCommand::UpdateStale(args) => cmd_workspace_update_stale(ui, command, args),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue