From 7c24e7bfe7d45d2ebacdc6502788777290924589 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Tue, 9 May 2023 17:10:03 -0700 Subject: [PATCH] `jj debug operation`: Create a `debug view` alias, arguments that determine what to show --- src/commands/mod.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index af7cd9998..1a71b2307 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -944,6 +944,7 @@ enum DebugCommands { Index(DebugIndexArgs), #[command(name = "reindex")] ReIndex(DebugReIndexArgs), + #[command(visible_alias = "view")] Operation(DebugOperationArgs), } @@ -976,6 +977,18 @@ struct DebugReIndexArgs {} struct DebugOperationArgs { #[arg(default_value = "@")] operation: String, + #[arg(long, value_enum, default_value = "all")] + display: DebugOperationDisplay, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] +enum DebugOperationDisplay { + /// Show only the operation details. + Operation, + /// Show only the view details + View, + /// Show both the view and the operation + All, } fn add_to_git_exclude(ui: &mut Ui, git_repo: &git2::Repository) -> Result<(), CommandError> { @@ -3200,8 +3213,12 @@ fn cmd_debug( DebugCommands::Operation(operation_args) => { let workspace_command = command.workspace_helper(ui)?; let op = workspace_command.resolve_single_op(&operation_args.operation)?; - writeln!(ui, "{:#?}", op.store_operation())?; - writeln!(ui, "{:#?}", op.view().store_view())?; + if operation_args.display != DebugOperationDisplay::View { + writeln!(ui, "{:#?}", op.store_operation())?; + } + if operation_args.display != DebugOperationDisplay::Operation { + writeln!(ui, "{:#?}", op.view().store_view())?; + } } } Ok(())