mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-19 19:08:08 +00:00
cli: rename --verbose to --debug to better fit what it does
This commit is contained in:
parent
06d67f02d8
commit
0fc5005b8a
9 changed files with 28 additions and 26 deletions
|
@ -53,6 +53,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
* `jj git fetch` now automatically prints new remote branches and tags by default.
|
||||
|
||||
* `--verbose/-v` is now `--debug` (no short option since it's not intended to be used often)
|
||||
|
||||
### Fixed bugs
|
||||
|
||||
* On Windows, symlinks in the repo are now materialized as regular files in the
|
||||
|
|
|
@ -555,15 +555,15 @@ impl TracingSubscription {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn enable_verbose_logging(&self) -> Result<(), CommandError> {
|
||||
pub fn enable_debug_logging(&self) -> Result<(), CommandError> {
|
||||
self.reload_log_filter
|
||||
.modify(|filter| {
|
||||
*filter = tracing_subscriber::EnvFilter::builder()
|
||||
.with_default_directive(tracing::metadata::LevelFilter::DEBUG.into())
|
||||
.from_env_lossy()
|
||||
})
|
||||
.map_err(|err| internal_error_with_message("failed to enable verbose logging", err))?;
|
||||
tracing::info!("verbose logging enabled");
|
||||
.map_err(|err| internal_error_with_message("failed to enable debug logging", err))?;
|
||||
tracing::info!("debug logging enabled");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -2497,9 +2497,9 @@ pub struct GlobalArgs {
|
|||
/// do that, but it is possible.
|
||||
#[arg(long, visible_alias = "at-op", global = true, default_value = "@")]
|
||||
pub at_operation: String,
|
||||
/// Enable verbose logging
|
||||
#[arg(long, short = 'v', global = true)]
|
||||
pub verbose: bool,
|
||||
/// Enable debug logging
|
||||
#[arg(long, global = true)]
|
||||
pub debug: bool,
|
||||
|
||||
#[command(flatten)]
|
||||
pub early_args: EarlyArgs,
|
||||
|
@ -2743,9 +2743,9 @@ pub fn parse_args(
|
|||
.try_get_matches_from(string_args)?;
|
||||
|
||||
let args: Args = Args::from_arg_matches(&matches).unwrap();
|
||||
if args.global_args.verbose {
|
||||
// TODO: set up verbose logging as early as possible
|
||||
tracing_subscription.enable_verbose_logging()?;
|
||||
if args.global_args.debug {
|
||||
// TODO: set up debug logging as early as possible
|
||||
tracing_subscription.enable_debug_logging()?;
|
||||
}
|
||||
|
||||
Ok((matches, args))
|
||||
|
|
|
@ -116,9 +116,9 @@ pub enum ExternalToolError {
|
|||
MergeArgsNotConfigured { tool_name: String },
|
||||
#[error("Error setting up temporary directory")]
|
||||
SetUpDir(#[source] std::io::Error),
|
||||
// TODO: Remove the "(run with --verbose to see the exact invocation)"
|
||||
// from this and other errors. Print it as a hint but only if --verbose is *not* set.
|
||||
#[error("Error executing '{tool_binary}' (run with --verbose to see the exact invocation)")]
|
||||
// TODO: Remove the "(run with --debug to see the exact invocation)"
|
||||
// from this and other errors. Print it as a hint but only if --debug is *not* set.
|
||||
#[error("Error executing '{tool_binary}' (run with --debug to see the exact invocation)")]
|
||||
FailedToExecute {
|
||||
tool_binary: String,
|
||||
#[source]
|
||||
|
@ -575,7 +575,7 @@ fn format_tool_aborted(exit_status: &ExitStatus) -> String {
|
|||
.map(|c| c.to_string())
|
||||
.unwrap_or_else(|| "<unknown>".to_string());
|
||||
format!(
|
||||
"Tool exited with a non-zero code (run with --verbose to see the exact invocation). Exit \
|
||||
"Tool exited with a non-zero code (run with --debug to see the exact invocation). Exit \
|
||||
code: {code}."
|
||||
)
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ pub enum ConflictResolveError {
|
|||
#[error("The conflict at {path:?} has {sides} sides. At most 2 sides are supported.")]
|
||||
ConflictTooComplicated { path: RepoPathBuf, sides: usize },
|
||||
#[error(
|
||||
"The output file is either unchanged or empty after the editor quit (run with --verbose \
|
||||
to see the exact invocation)."
|
||||
"The output file is either unchanged or empty after the editor quit (run with --debug to \
|
||||
see the exact invocation)."
|
||||
)]
|
||||
EmptyOrUnchanged,
|
||||
#[error("Backend error")]
|
||||
|
|
|
@ -154,7 +154,7 @@ repository.
|
|||
* `--at-operation <AT_OPERATION>` — Operation to load the repo at
|
||||
|
||||
Default value: `@`
|
||||
* `-v`, `--verbose` — Enable verbose logging
|
||||
* `--debug` — Enable debug logging
|
||||
|
||||
Possible values: `true`, `false`
|
||||
|
||||
|
|
|
@ -751,7 +751,7 @@ fn test_diff_external_tool() {
|
|||
diff
|
||||
"###);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Tool exited with a non-zero code (run with --verbose to see the exact invocation). Exit code: 1.
|
||||
Tool exited with a non-zero code (run with --debug to see the exact invocation). Exit code: 1.
|
||||
"###);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ fn test_diffedit() {
|
|||
std::fs::write(&edit_script, "rm file2\0fail").unwrap();
|
||||
insta::assert_snapshot!(&test_env.jj_cmd_failure(&repo_path, &["diffedit"]), @r###"
|
||||
Error: Failed to edit diff
|
||||
Caused by: Tool exited with a non-zero code (run with --verbose to see the exact invocation). Exit code: 1.
|
||||
Caused by: Tool exited with a non-zero code (run with --debug to see the exact invocation). Exit code: 1.
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
|
@ -395,7 +395,7 @@ fn test_diffedit_old_restore_interactive_tests() {
|
|||
std::fs::write(&edit_script, "rm file2\0fail").unwrap();
|
||||
insta::assert_snapshot!(&test_env.jj_cmd_failure(&repo_path, &["diffedit", "--from", "@-"]), @r###"
|
||||
Error: Failed to edit diff
|
||||
Caused by: Tool exited with a non-zero code (run with --verbose to see the exact invocation). Exit code: 1.
|
||||
Caused by: Tool exited with a non-zero code (run with --debug to see the exact invocation). Exit code: 1.
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
|
|
|
@ -446,7 +446,7 @@ fn test_help() {
|
|||
-R, --repository <REPOSITORY> Path to repository to operate on
|
||||
--ignore-working-copy Don't snapshot the working copy, and don't update it
|
||||
--at-operation <AT_OPERATION> Operation to load the repo at [default: @] [aliases: at-op]
|
||||
-v, --verbose Enable verbose logging
|
||||
--debug Enable debug logging
|
||||
--color <WHEN> When to colorize output (always, never, auto)
|
||||
--no-pager Disable the pager
|
||||
--config-toml <TOML> Additional configuration options (can be repeated)
|
||||
|
@ -454,22 +454,22 @@ fn test_help() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_verbose_logging_enabled() {
|
||||
// Test that the verbose flag enabled verbose logging
|
||||
fn test_debug_logging_enabled() {
|
||||
// Test that the debug flag enabled debug logging
|
||||
let test_env = TestEnvironment::default();
|
||||
|
||||
let (_stdout, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["version", "-v"]);
|
||||
let (_stdout, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["version", "--debug"]);
|
||||
// Split the first log line into a timestamp and the rest.
|
||||
// The timestamp is constant sized so this is a robust operation.
|
||||
// Example timestamp: 2022-11-20T06:24:05.477703Z
|
||||
let (_timestamp, log_line) = stderr
|
||||
.lines()
|
||||
.next()
|
||||
.expect("verbose logging on first line")
|
||||
.expect("debug logging on first line")
|
||||
.split_at(36);
|
||||
// The log format is currently Pretty so we include the terminal markup.
|
||||
// Luckily, insta will print this in colour when reviewing.
|
||||
insta::assert_snapshot!(log_line, @"[32m INFO[0m [2mjj_cli::cli_util[0m[2m:[0m verbose logging enabled");
|
||||
insta::assert_snapshot!(log_line, @"[32m INFO[0m [2mjj_cli::cli_util[0m[2m:[0m debug logging enabled");
|
||||
}
|
||||
|
||||
fn strip_last_line(s: &str) -> &str {
|
||||
|
|
|
@ -299,7 +299,7 @@ fn check_resolve_produces_input_file(
|
|||
assert_eq!(
|
||||
&test_env.jj_cmd_failure(repo_path, &["resolve", "--config-toml", &merge_arg_config]),
|
||||
"Resolving conflicts in: file\nError: Failed to resolve conflicts\nCaused by: The output \
|
||||
file is either unchanged or empty after the editor quit (run with --verbose to see the \
|
||||
file is either unchanged or empty after the editor quit (run with --debug to see the \
|
||||
exact invocation).\n"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue