help: add more keyword topics (for jj help -k)
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
nix / flake check (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with latest Python and uv (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

We have the keyword-help feature now so let's use it a bit more. I'm
not sure how we should advertise it better, but that's a different
topic anyway.
This commit is contained in:
Martin von Zweigbergk 2024-12-15 15:49:22 -08:00 committed by Martin von Zweigbergk
parent c82483b088
commit 8907e692d4
3 changed files with 44 additions and 10 deletions

View file

@ -95,11 +95,36 @@ struct Keyword {
//
// Maybe we can steal some ideas from https://github.com/martinvonz/jj/pull/3130
const KEYWORDS: &[Keyword] = &[
Keyword {
name: "bookmarks",
description: "Named pointers to revisions (similar to Git's branches)",
content: include_str!(concat!("../../", env!("JJ_DOCS_DIR"), "bookmarks.md")),
},
Keyword {
name: "config",
description: "How and where to set configuration options",
content: include_str!(concat!("../../", env!("JJ_DOCS_DIR"), "config.md")),
},
Keyword {
name: "filesets",
description: "A functional language for selecting a set of files",
content: include_str!(concat!("../../", env!("JJ_DOCS_DIR"), "filesets.md")),
},
Keyword {
name: "glossary",
description: "Definitions of various terms",
content: include_str!(concat!("../../", env!("JJ_DOCS_DIR"), "glossary.md")),
},
Keyword {
name: "revsets",
description: "A functional language for selecting a set of revision",
content: include_str!(concat!("../../", env!("JJ_DOCS_DIR"), "revsets.md")),
},
Keyword {
name: "templates",
description: "A functional language to customize command output",
content: include_str!(concat!("../../", env!("JJ_DOCS_DIR"), "templates.md")),
},
Keyword {
name: "tutorial",
description: "Show a tutorial to get started with jj",

View file

@ -1,7 +1,6 @@
---
source: cli/tests/test_generate_md_cli_help.rs
description: "AUTO-GENERATED FILE, DO NOT EDIT. This cli reference is generated by a test as an `insta` snapshot. MkDocs includes this snapshot from docs/cli-reference.md."
snapshot_kind: text
---
<!-- BEGIN MARKDOWN-->
@ -1278,8 +1277,18 @@ Print this message or the help of the given subcommand(s)
* `-k`, `--keyword <KEYWORD>` — Show help for keywords instead of commands
Possible values:
- `bookmarks`:
Named pointers to revisions (similar to Git's branches)
- `config`:
How and where to set configuration options
- `filesets`:
A functional language for selecting a set of files
- `glossary`:
Definitions of various terms
- `revsets`:
A functional language for selecting a set of revision
- `templates`:
A functional language to customize command output
- `tutorial`:
Show a tutorial to get started with jj

View file

@ -102,33 +102,33 @@ fn test_help_keyword() {
// It should give hints if a similar keyword is present
let help_cmd_stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["help", "-k", "rev"]);
insta::assert_snapshot!(help_cmd_stderr, @r#"
insta::assert_snapshot!(help_cmd_stderr, @r###"
error: invalid value 'rev' for '--keyword <KEYWORD>'
[possible values: revsets, tutorial]
[possible values: bookmarks, config, filesets, glossary, revsets, templates, tutorial]
tip: a similar value exists: 'revsets'
For more information, try '--help'.
"#);
"###);
// It should give error with a hint if no similar keyword is found
let help_cmd_stderr =
test_env.jj_cmd_cli_error(test_env.env_root(), &["help", "-k", "<no-similar-keyword>"]);
insta::assert_snapshot!(help_cmd_stderr, @r#"
insta::assert_snapshot!(help_cmd_stderr, @r###"
error: invalid value '<no-similar-keyword>' for '--keyword <KEYWORD>'
[possible values: revsets, tutorial]
[possible values: bookmarks, config, filesets, glossary, revsets, templates, tutorial]
For more information, try '--help'.
"#);
"###);
// The keyword flag with no argument should error with a hint
let help_cmd_stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["help", "-k"]);
insta::assert_snapshot!(help_cmd_stderr, @r#"
insta::assert_snapshot!(help_cmd_stderr, @r###"
error: a value is required for '--keyword <KEYWORD>' but none was supplied
[possible values: revsets, tutorial]
[possible values: bookmarks, config, filesets, glossary, revsets, templates, tutorial]
For more information, try '--help'.
"#);
"###);
// It shouldn't show help for a certain keyword if the `--keyword` is not
// present