Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: sort debug/git subcommands, rename "debug workingcopy" #3918

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions cli/src/commands/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ use crate::ui::Ui;
#[command(hide = true)]
pub enum DebugCommand {
Fileset(FilesetArgs),
Revset(RevsetArgs),
#[command(name = "workingcopy")]
WorkingCopy(WorkingCopyArgs),
Template(TemplateArgs),
Index(IndexArgs),
Reindex(ReindexArgs),
#[command(visible_alias = "view")]
Operation(OperationArgs),
Reindex(ReindexArgs),
Revset(RevsetArgs),
Snapshot(SnapshotArgs),
Template(TemplateArgs),
Tree(TreeArgs),
#[command(subcommand)]
Watchman(WatchmanCommand),
Snapshot(SnapshotArgs),
WorkingCopy(WorkingCopyArgs),
}

pub fn cmd_debug(
Expand All @@ -69,15 +68,15 @@ pub fn cmd_debug(
) -> Result<(), CommandError> {
match subcommand {
DebugCommand::Fileset(args) => cmd_debug_fileset(ui, command, args),
DebugCommand::Revset(args) => cmd_debug_revset(ui, command, args),
DebugCommand::WorkingCopy(args) => cmd_debug_working_copy(ui, command, args),
DebugCommand::Template(args) => cmd_debug_template(ui, command, args),
DebugCommand::Index(args) => cmd_debug_index(ui, command, args),
DebugCommand::Reindex(args) => cmd_debug_reindex(ui, command, args),
DebugCommand::Operation(args) => cmd_debug_operation(ui, command, args),
DebugCommand::Reindex(args) => cmd_debug_reindex(ui, command, args),
DebugCommand::Revset(args) => cmd_debug_revset(ui, command, args),
DebugCommand::Snapshot(args) => cmd_debug_snapshot(ui, command, args),
DebugCommand::Template(args) => cmd_debug_template(ui, command, args),
DebugCommand::Tree(args) => cmd_debug_tree(ui, command, args),
DebugCommand::Watchman(args) => cmd_debug_watchman(ui, command, args),
DebugCommand::Snapshot(args) => cmd_debug_snapshot(ui, command, args),
DebugCommand::WorkingCopy(args) => cmd_debug_working_copy(ui, command, args),
}
}

Expand Down
46 changes: 23 additions & 23 deletions cli/src/commands/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,35 @@ use crate::ui::Ui;
/// https://github.com/martinvonz/jj/blob/main/docs/git-comparison.md.
#[derive(Subcommand, Clone, Debug)]
pub enum GitCommand {
#[command(subcommand)]
Remote(RemoteCommand),
Init(InitArgs),
Fetch(FetchArgs),
Clone(CloneArgs),
Push(PushArgs),
Import(ImportArgs),
Export(ExportArgs),
Fetch(FetchArgs),
Import(ImportArgs),
Init(InitArgs),
Push(PushArgs),
#[command(subcommand)]
Remote(RemoteCommand),
#[command(subcommand, hide = true)]
Submodule(SubmoduleCommand),
}

pub fn cmd_git(
ui: &mut Ui,
command: &CommandHelper,
subcommand: &GitCommand,
) -> Result<(), CommandError> {
match subcommand {
GitCommand::Clone(args) => cmd_git_clone(ui, command, args),
GitCommand::Export(args) => cmd_git_export(ui, command, args),
GitCommand::Fetch(args) => cmd_git_fetch(ui, command, args),
GitCommand::Import(args) => cmd_git_import(ui, command, args),
GitCommand::Init(args) => cmd_git_init(ui, command, args),
GitCommand::Push(args) => cmd_git_push(ui, command, args),
GitCommand::Remote(args) => cmd_git_remote(ui, command, args),
GitCommand::Submodule(args) => cmd_git_submodule(ui, command, args),
}
}

fn map_git_error(err: git2::Error) -> CommandError {
if err.class() == git2::ErrorClass::Ssh {
let hint =
Expand Down Expand Up @@ -95,20 +112,3 @@ fn get_single_remote(git_repo: &git2::Repository) -> Result<Option<String>, Comm
_ => None,
})
}

pub fn cmd_git(
ui: &mut Ui,
command: &CommandHelper,
subcommand: &GitCommand,
) -> Result<(), CommandError> {
match subcommand {
GitCommand::Init(args) => cmd_git_init(ui, command, args),
GitCommand::Fetch(args) => cmd_git_fetch(ui, command, args),
GitCommand::Clone(args) => cmd_git_clone(ui, command, args),
GitCommand::Remote(args) => cmd_git_remote(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(args) => cmd_git_submodule(ui, command, args),
}
}
4 changes: 2 additions & 2 deletions cli/src/commands/git/remote/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ use crate::ui::Ui;
#[derive(Subcommand, Clone, Debug)]
pub enum RemoteCommand {
Add(AddArgs),
List(ListArgs),
Remove(RemoveArgs),
Rename(RenameArgs),
List(ListArgs),
}

pub fn cmd_git_remote(
Expand All @@ -45,8 +45,8 @@ pub fn cmd_git_remote(
) -> Result<(), CommandError> {
match subcommand {
RemoteCommand::Add(args) => cmd_remote_add(ui, command, args),
RemoteCommand::List(args) => cmd_remote_list(ui, command, args),
RemoteCommand::Remove(args) => cmd_remote_remove(ui, command, args),
RemoteCommand::Rename(args) => cmd_remote_rename(ui, command, args),
RemoteCommand::List(args) => cmd_remote_list(ui, command, args),
}
}
Loading
Loading