Skip to content

Commit

Permalink
jj debug operation: Create a debug view alias, arguments that det…
Browse files Browse the repository at this point in the history
…ermine what to show
  • Loading branch information
ilyagr committed May 15, 2023
1 parent f8a534c commit 95fb261
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ enum DebugCommands {
Index(DebugIndexArgs),
#[command(name = "reindex")]
ReIndex(DebugReIndexArgs),
#[command(visible_alias = "view")]
Operation(DebugOperationArgs),
}

Expand Down Expand Up @@ -975,6 +976,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> {
Expand Down Expand Up @@ -3194,8 +3207,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(())
Expand Down

0 comments on commit 95fb261

Please sign in to comment.