mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-24 12:48:55 +00:00
cli: move some debug
commands to new (non-hidden) support
group
The `jj debug` commands are hidden from help and are described as "Low-level commands not intended for users", but e.g. `jj debug completion` is intended for users, and should be visible in the help output.
This commit is contained in:
parent
ce098a729a
commit
e2b4d7058d
6 changed files with 114 additions and 74 deletions
|
@ -50,6 +50,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* `jj hide` (alias for `jj abandon`) is no longer available. Use `jj abandon`
|
||||
instead.
|
||||
|
||||
* `jj debug completion`, `jj debug mangen` and `jj debug config-schema` have
|
||||
been moved from `jj debug` to `jj support`.
|
||||
|
||||
### Fixed bugs
|
||||
|
||||
* Modify/delete conflicts now include context lines
|
||||
|
|
10
README.md
10
README.md
|
@ -254,30 +254,30 @@ email = "martinvonz@google.com"
|
|||
## Command-line completion
|
||||
|
||||
To set up command-line completion, source the output of
|
||||
`jj debug completion --bash/--zsh/--fish`. Exactly how to source it depends on
|
||||
`jj support completion --bash/--zsh/--fish`. Exactly how to source it depends on
|
||||
your shell.
|
||||
|
||||
### Bash
|
||||
```shell script
|
||||
source <(jj debug completion) # --bash is the default
|
||||
source <(jj support completion) # --bash is the default
|
||||
```
|
||||
|
||||
### Zsh
|
||||
```shell script
|
||||
autoload -U compinit
|
||||
compinit
|
||||
source <(jj debug completion --zsh | sed '$d') # remove the last line
|
||||
source <(jj support completion --zsh | sed '$d') # remove the last line
|
||||
compdef _jj jj
|
||||
```
|
||||
|
||||
### Fish
|
||||
```shell script
|
||||
jj debug completion --fish | source
|
||||
jj support completion --fish | source
|
||||
```
|
||||
|
||||
### Xonsh
|
||||
```shell script
|
||||
source-bash $(jj debug completion)
|
||||
source-bash $(jj support completion)
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -63,14 +63,14 @@
|
|||
libiconv
|
||||
];
|
||||
postInstall = ''
|
||||
$out/bin/jj debug mangen > ./jj.1
|
||||
$out/bin/jj support mangen > ./jj.1
|
||||
installManPage ./jj.1
|
||||
|
||||
$out/bin/jj debug completion --bash > ./completions.bash
|
||||
$out/bin/jj support completion --bash > ./completions.bash
|
||||
installShellCompletion --bash --name ${pname}.bash ./completions.bash
|
||||
$out/bin/jj debug completion --fish > ./completions.fish
|
||||
$out/bin/jj support completion --fish > ./completions.fish
|
||||
installShellCompletion --fish --name ${pname}.fish ./completions.fish
|
||||
$out/bin/jj debug completion --zsh > ./completions.zsh
|
||||
$out/bin/jj support completion --zsh > ./completions.zsh
|
||||
installShellCompletion --zsh --name _${pname} ./completions.zsh
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -109,6 +109,8 @@ enum Commands {
|
|||
Split(SplitArgs),
|
||||
Squash(SquashArgs),
|
||||
Status(StatusArgs),
|
||||
#[command(subcommand)]
|
||||
Support(SupportCommands),
|
||||
/// Undo an operation (shortcut for `jj op undo`)
|
||||
Undo(operation::OperationUndoArgs),
|
||||
Unsquash(UnsquashArgs),
|
||||
|
@ -866,13 +868,55 @@ struct SparseArgs {
|
|||
list: bool,
|
||||
}
|
||||
|
||||
/// Infrequently used commands such as for generating shell completions
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
enum SupportCommands {
|
||||
Completion(SupportCompletionArgs),
|
||||
Mangen(SupportMangenArgs),
|
||||
ConfigSchema(SupportConfigSchemaArgs),
|
||||
}
|
||||
|
||||
/// Print a command-line-completion script
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct SupportCompletionArgs {
|
||||
/// Print a completion script for Bash
|
||||
///
|
||||
/// Apply it by running this:
|
||||
///
|
||||
/// source <(jj support completion)
|
||||
#[arg(long, verbatim_doc_comment)]
|
||||
bash: bool,
|
||||
/// Print a completion script for Fish
|
||||
///
|
||||
/// Apply it by running this:
|
||||
///
|
||||
/// jj support completion --fish | source
|
||||
#[arg(long, verbatim_doc_comment)]
|
||||
fish: bool,
|
||||
/// Print a completion script for Zsh
|
||||
///
|
||||
/// Apply it by running this:
|
||||
///
|
||||
/// autoload -U compinit
|
||||
/// compinit
|
||||
/// source <(jj support completion --zsh | sed '$d') # remove the last line
|
||||
/// compdef _jj jj
|
||||
#[arg(long, verbatim_doc_comment)]
|
||||
zsh: bool,
|
||||
}
|
||||
|
||||
/// Print a ROFF (manpage)
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct SupportMangenArgs {}
|
||||
|
||||
/// Print the JSON schema for the jj TOML config format.
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct SupportConfigSchemaArgs {}
|
||||
|
||||
/// Low-level commands not intended for users
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
#[command(hide = true)]
|
||||
enum DebugCommands {
|
||||
Completion(DebugCompletionArgs),
|
||||
Mangen(DebugMangenArgs),
|
||||
ConfigSchema(DebugConfigSchemaArgs),
|
||||
#[command(name = "resolverev")]
|
||||
ResolveRev(DebugResolveRevArgs),
|
||||
#[command(name = "workingcopy")]
|
||||
|
@ -884,43 +928,6 @@ enum DebugCommands {
|
|||
Operation(DebugOperationArgs),
|
||||
}
|
||||
|
||||
/// Print a command-line-completion script
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct DebugCompletionArgs {
|
||||
/// Print a completion script for Bash
|
||||
///
|
||||
/// Apply it by running this:
|
||||
///
|
||||
/// source <(jj debug completion)
|
||||
#[arg(long, verbatim_doc_comment)]
|
||||
bash: bool,
|
||||
/// Print a completion script for Fish
|
||||
///
|
||||
/// Apply it by running this:
|
||||
///
|
||||
/// jj debug completion --fish | source
|
||||
#[arg(long, verbatim_doc_comment)]
|
||||
fish: bool,
|
||||
/// Print a completion script for Zsh
|
||||
///
|
||||
/// Apply it by running this:
|
||||
///
|
||||
/// autoload -U compinit
|
||||
/// compinit
|
||||
/// source <(jj debug completion --zsh | sed '$d') # remove the last line
|
||||
/// compdef _jj jj
|
||||
#[arg(long, verbatim_doc_comment)]
|
||||
zsh: bool,
|
||||
}
|
||||
|
||||
/// Print a ROFF (manpage)
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct DebugMangenArgs {}
|
||||
|
||||
/// Print the JSON schema for the jj TOML config format.
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct DebugConfigSchemaArgs {}
|
||||
|
||||
/// Resolve a revision identifier to its full ID
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct DebugResolveRevArgs {
|
||||
|
@ -3036,13 +3043,13 @@ fn make_branch_term(branch_names: &[impl AsRef<str>]) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn cmd_debug(
|
||||
fn cmd_support(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &DebugCommands,
|
||||
subcommand: &SupportCommands,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
DebugCommands::Completion(completion_matches) => {
|
||||
SupportCommands::Completion(completion_matches) => {
|
||||
let mut app = command.app().clone();
|
||||
let mut buf = vec![];
|
||||
let shell = if completion_matches.zsh {
|
||||
|
@ -3055,17 +3062,27 @@ fn cmd_debug(
|
|||
clap_complete::generate(shell, &mut app, "jj", &mut buf);
|
||||
ui.stdout_formatter().write_all(&buf)?;
|
||||
}
|
||||
DebugCommands::Mangen(_mangen_matches) => {
|
||||
SupportCommands::Mangen(_mangen_matches) => {
|
||||
let mut buf = vec![];
|
||||
let man = clap_mangen::Man::new(command.app().clone());
|
||||
man.render(&mut buf)?;
|
||||
ui.stdout_formatter().write_all(&buf)?;
|
||||
}
|
||||
DebugCommands::ConfigSchema(_config_schema_matches) => {
|
||||
SupportCommands::ConfigSchema(_config_schema_matches) => {
|
||||
// TODO(#879): Consider generating entire schema dynamically vs. static file.
|
||||
let buf = include_bytes!("../config-schema.json");
|
||||
ui.stdout_formatter().write_all(buf)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cmd_debug(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
subcommand: &DebugCommands,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
DebugCommands::ResolveRev(resolve_matches) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let commit = workspace_command.resolve_single_rev(&resolve_matches.revision)?;
|
||||
|
@ -3446,6 +3463,7 @@ pub fn run_command(
|
|||
Commands::Workspace(sub_args) => cmd_workspace(ui, command_helper, sub_args),
|
||||
Commands::Sparse(sub_args) => cmd_sparse(ui, command_helper, sub_args),
|
||||
Commands::Git(sub_args) => git::cmd_git(ui, command_helper, sub_args),
|
||||
Commands::Support(sub_args) => cmd_support(ui, command_helper, sub_args),
|
||||
Commands::Debug(sub_args) => cmd_debug(ui, command_helper, sub_args),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,26 +19,6 @@ use crate::common::TestEnvironment;
|
|||
|
||||
pub mod common;
|
||||
|
||||
#[test]
|
||||
fn test_debug_config_schema() {
|
||||
let test_env = TestEnvironment::default();
|
||||
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["debug", "config-schema"]);
|
||||
// Validate partial snapshot, redacting any lines nested 2+ indent levels.
|
||||
insta::with_settings!({filters => vec![(r"(?m)(^ .*$\r?\n)+", " [...]\n")]}, {
|
||||
assert_snapshot!(stdout, @r###"
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"title": "Jujutsu config",
|
||||
"type": "object",
|
||||
"description": "User configuration for Jujutsu VCS. See https://github.com/martinvonz/jj/blob/main/docs/config.md for details",
|
||||
"properties": {
|
||||
[...]
|
||||
}
|
||||
}
|
||||
"###)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_debug_index() {
|
||||
let test_env = TestEnvironment::default();
|
||||
|
|
39
tests/test_support_command.rs
Normal file
39
tests/test_support_command.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2023 The Jujutsu Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use insta::assert_snapshot;
|
||||
|
||||
use crate::common::TestEnvironment;
|
||||
|
||||
pub mod common;
|
||||
|
||||
#[test]
|
||||
fn test_support_config_schema() {
|
||||
let test_env = TestEnvironment::default();
|
||||
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["support", "config-schema"]);
|
||||
// Validate partial snapshot, redacting any lines nested 2+ indent levels.
|
||||
insta::with_settings!({filters => vec![(r"(?m)(^ .*$\r?\n)+", " [...]\n")]}, {
|
||||
assert_snapshot!(stdout, @r###"
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"title": "Jujutsu config",
|
||||
"type": "object",
|
||||
"description": "User configuration for Jujutsu VCS. See https://github.com/martinvonz/jj/blob/main/docs/config.md for details",
|
||||
"properties": {
|
||||
[...]
|
||||
}
|
||||
}
|
||||
"###)
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue