From 99e69e31700aa5ccd9aea585b3d9afb4caa88ac1 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 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 97e604aa9db..263926cda9c 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -943,6 +943,7 @@ enum DebugCommands { Index(DebugIndexArgs), #[command(name = "reindex")] ReIndex(DebugReIndexArgs), + #[command(visible_alias = "view")] Operation(DebugOperationArgs), } @@ -975,6 +976,20 @@ 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. This includes the randomly generated + /// operation id + // TODO: Make operation ids determenistic in tests + 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> { @@ -3194,8 +3209,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(())