carapace-sh / carapace-bin

multi-shell multi-command argument completer
https://carapace.sh
MIT License
885 stars 48 forks source link

Completions for `jj` #1968

Closed BatmanAoD closed 12 months ago

BatmanAoD commented 12 months ago

Request

I'm trying to adopt jj (github) as my CLI of choice for interacting with Git repos. Currently, it doesn't have completions in either Carapace or Nushell, which is making it harder than necessary to use.

Proposed solution

jj uses Clap, so I'm guessing the spec-generator can be used.

Anything else?

No response

rsteube commented 12 months ago

Oh, haven't heard of that before. Got the the generator working:

Click to expand ```yaml name: jj description: Jujutsu (An experimental VCS) flags: -h, --help: Print help (see more with '--help') -V, --version: Print version persistentflags: --at-operation=: Operation to load the repo at --color=: When to colorize output (always, never, auto) --config-toml=*: Additional configuration options (can be repeated) --ignore-working-copy: Don't snapshot the working copy, and don't update it --no-pager: Disable the pager -R, --repository=: Path to repository to operate on -v, --verbose: Enable verbose logging completion: flag: repository: - $directories commands: - name: abandon description: Abandon a revision flags: -h, --help: Print help (see more with '--help') -s, --summary: Do not print every abandoned commit on a separate line completion: flag: repository: - $directories - name: backout description: Apply the reverse of a revision on top of another revision flags: -d, --destination=*: The revision to apply the reverse changes on top of -h, --help: Print help (see more with '--help') -r, --revision=: The revision to apply the reverse of completion: flag: repository: - $directories - name: branch description: Manage branches flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: create aliases: - c description: Create a new branch flags: -h, --help: Print help (see more with '--help') -r, --revision=: The branch's target revision completion: flag: repository: - $directories - name: delete aliases: - d description: Delete an existing branch and propagate the deletion to remotes on the next push flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: forget aliases: - f description: Forget everything about a branch, including its local and remote targets flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: list aliases: - l description: List branches and their targets flags: -a, --all: Show all tracking and non-tracking remote branches including the ones whose targets are synchronized with the local branches -h, --help: Print help (see more with '--help') -r, --revisions=*: Show branches whose local targets are in the given revisions completion: flag: repository: - $directories - name: set aliases: - s description: Update a given branch to point to a certain commit flags: -B, --allow-backwards: Allow moving the branch backwards or sideways -h, --help: Print help (see more with '--help') -r, --revision=: The branch's target revision completion: flag: repository: - $directories - name: track description: Start tracking given remote branches flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: untrack description: Stop tracking given remote branches flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: help description: Print this message or the help of the given subcommand(s) commands: - name: create description: Create a new branch - name: delete description: Delete an existing branch and propagate the deletion to remotes on the next push - name: forget description: Forget everything about a branch, including its local and remote targets - name: list description: List branches and their targets - name: set description: Update a given branch to point to a certain commit - name: track description: Start tracking given remote branches - name: untrack description: Stop tracking given remote branches - name: help description: Print this message or the help of the given subcommand(s) - name: cat aliases: - print description: Print contents of a file in a revision flags: -h, --help: Print help (see more with '--help') -r, --revision=: The revision to get the file contents from completion: flag: repository: - $directories positional: - - $files - name: checkout aliases: - co description: Create a new, empty change and edit it in the working copy flags: -h, --help: Print help (see more with '--help') -m, --message=*: The change description to use completion: flag: repository: - $directories positional: - [] - name: chmod description: Sets or removes the executable bit for paths in the repo flags: -h, --help: Print help (see more with '--help') -r, --revision=: The revision to update completion: flag: repository: - $directories positional: - - "n\tMake a path non-executable (alias: normal)" - "x\tMake a path executable (alias: executable)" positionalany: - $files - name: commit aliases: - ci description: Update the description and create a new change on top flags: -h, --help: Print help (see more with '--help') -i, --interactive: Interactively choose which changes to include in the first commit -m, --message=*: The change description to use (don't open editor) completion: flag: repository: - $directories positionalany: - $files - name: config description: Manage config options flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: list aliases: - l description: List variables set in config file, along with their values flags: -h, --help: Print help (see more with '--help') --include-defaults: Whether to explicitly include built-in default values in the list completion: flag: repository: - $directories positional: - [] - name: get aliases: - g description: Get the value of a given config option. flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - [] - name: set aliases: - s description: Update config file to set the given option to a given value flags: -h, --help: Print help (see more with '--help') --repo: Target the repo-level config --user: Target the user-level config completion: flag: repository: - $directories positional: - [] - [] - name: edit aliases: - e description: Start an editor on a jj config file flags: -h, --help: Print help (see more with '--help') --repo: Target the repo-level config --user: Target the user-level config completion: flag: repository: - $directories - name: help description: Print this message or the help of the given subcommand(s) commands: - name: list description: List variables set in config file, along with their values - name: get description: Get the value of a given config option. - name: set description: Update config file to set the given option to a given value - name: edit description: Start an editor on a jj config file - name: help description: Print this message or the help of the given subcommand(s) - name: describe aliases: - desc description: Update the change description or other metadata flags: -h, --help: Print help (see more with '--help') -m, --message=*: The change description to use (don't open editor) --no-edit: Don't open an editor --reset-author: Reset the author to the configured user --stdin: Read the change description from stdin completion: flag: repository: - $directories positional: - [] - name: diff description: '' flags: --color-words: Show a word-level diff with changes indicated only by color --from=: Show changes from this revision --git: Show a Git-format diff -h, --help: Print help (see more with '--help') -r, --revision=: Show changes in this revision, compared to its parent(s) --stat: Show a histogram of the changes -s, --summary: For each path, show only whether it was modified, added, or removed --to=: Show changes to this revision --tool=: Generate diff by external command --types: For each path, show only its type before and after completion: flag: repository: - $directories positionalany: - $files - name: diffedit description: Touch up the content changes in a revision with a diff editor flags: --from=: Show changes from this revision. Defaults to @ if --to is specified -h, --help: Print help (see more with '--help') -r, --revision=: The revision to touch up. Defaults to @ if neither --to nor --from are specified --to=: Edit changes in this revision. Defaults to @ if --from is specified completion: flag: repository: - $directories - name: duplicate description: Create a new change with the same content as an existing one flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: edit description: Edit a commit in the working copy flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - [] - name: files description: List files in a revision flags: -h, --help: Print help (see more with '--help') -r, --revision=: The revision to list files in completion: flag: repository: - $directories positionalany: - $files - name: git description: Commands for working with the underlying Git repo flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: remote description: Manage Git remotes flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: add description: Add a Git remote flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - [] - [] - name: remove description: Remove a Git remote and forget its branches flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - [] - name: rename description: Rename a Git remote flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - [] - [] - name: list description: List Git remotes flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: help description: Print this message or the help of the given subcommand(s) commands: - name: add description: Add a Git remote - name: remove description: Remove a Git remote and forget its branches - name: rename description: Rename a Git remote - name: list description: List Git remotes - name: help description: Print this message or the help of the given subcommand(s) - name: fetch description: Fetch from a Git remote flags: --all-remotes: Fetch from all remotes --branch=*: Fetch only some of the branches -h, --help: Print help (see more with '--help') --remote=*: The remote to fetch from (only named remotes are supported, can be repeated) completion: flag: repository: - $directories - name: clone description: Create a new repo backed by a clone of a Git repo flags: --colocate: Whether or not to colocate the Jujutsu repo with the git repo -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - - $directories - - $directories - name: push description: Push to a Git remote flags: --all: Push all branches (including deleted branches) -b, --branch=*: Push only this branch (can be repeated) -c, --change=*: Push this commit by creating a branch based on its change ID (can be repeated) --deleted: Push all deleted branches --dry-run: Only display what will change on the remote -h, --help: Print help (see more with '--help') --remote=: The remote to push to (only named remotes are supported) -r, --revisions=*: Push branches pointing to these commits completion: flag: repository: - $directories - name: import description: Update repo with changes made in the underlying Git repo flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: export description: Update the underlying Git repo with changes made in the repo flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: help description: Print this message or the help of the given subcommand(s) commands: - name: remote description: Manage Git remotes commands: - name: add description: Add a Git remote - name: remove description: Remove a Git remote and forget its branches - name: rename description: Rename a Git remote - name: list description: List Git remotes - name: fetch description: Fetch from a Git remote - name: clone description: Create a new repo backed by a clone of a Git repo - name: push description: Push to a Git remote - name: import description: Update repo with changes made in the underlying Git repo - name: export description: Update the underlying Git repo with changes made in the repo - name: help description: Print this message or the help of the given subcommand(s) - name: init description: Create a new repo in the given directory flags: --git: Use the Git backend, creating a jj repo backed by a Git repo --git-repo=: Path to a git repo the jj repo will be backed by -h, --help: Print help (see more with '--help') completion: flag: git-repo: - $directories repository: - $directories positional: - - $directories - name: interdiff description: Compare the changes of two commits flags: --color-words: Show a word-level diff with changes indicated only by color --from=: Show changes from this revision --git: Show a Git-format diff -h, --help: Print help (see more with '--help') --stat: Show a histogram of the changes -s, --summary: For each path, show only whether it was modified, added, or removed --to=: Show changes to this revision --tool=: Generate diff by external command --types: For each path, show only its type before and after completion: flag: repository: - $directories positionalany: - $files - name: log description: Show commit history flags: --color-words: Show a word-level diff with changes indicated only by color --git: Show a Git-format diff -h, --help: Print help (see more with '--help') -l, --limit=: Limit number of revisions to show --no-graph: Don't show the graph, show a flat list of revisions -p, --patch: Show patch --reversed: Show revisions in the opposite order (older revisions first) -r, --revisions=*: Which revisions to show. Defaults to the `revsets.log` setting, or `@ | ancestors(immutable_heads().., 2) | heads(immutable_heads())` if it is not set --stat: Show a histogram of the changes -s, --summary: For each path, show only whether it was modified, added, or removed -T, --template=: Render each revision using the given template --tool=: Generate diff by external command --types: For each path, show only its type before and after completion: flag: repository: - $directories positionalany: - $files - name: merge description: Merge work from multiple branches flags: -h, --help: Print help (see more with '--help') -A, --insert-after: Insert the new change between the target commit(s) and their children -B, --insert-before: Insert the new change between the target commit(s) and their parents -m, --message=*: The change description to use completion: flag: repository: - $directories - name: move description: Move changes from one revision into another flags: --from=: Move part of this change into the destination -h, --help: Print help (see more with '--help') -i, --interactive: Interactively choose which parts to move --to=: Move part of the source into this change completion: flag: repository: - $directories positionalany: - $files - name: new description: Create a new, empty change and edit it in the working copy flags: -h, --help: Print help (see more with '--help') -A, --insert-after: Insert the new change between the target commit(s) and their children -B, --insert-before: Insert the new change between the target commit(s) and their parents -m, --message=*: The change description to use completion: flag: repository: - $directories - name: next description: |- Move the current working copy commit to the next child revision in the repository. flags: --edit: Instead of creating a new working-copy commit on top of the target commit (like `jj new`), edit the target commit directly (like `jj edit`) -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - [] - name: obslog description: Show how a change has evolved flags: --color-words: Show a word-level diff with changes indicated only by color --git: Show a Git-format diff -h, --help: Print help (see more with '--help') -l, --limit=: Limit number of revisions to show --no-graph: Don't show the graph, show a flat list of revisions -p, --patch: Show patch compared to the previous version of this change -r, --revision=: '' --stat: Show a histogram of the changes -s, --summary: For each path, show only whether it was modified, added, or removed -T, --template=: Render each revision using the given template --tool=: Generate diff by external command --types: For each path, show only its type before and after completion: flag: repository: - $directories - name: operation aliases: - op description: Commands for working with the operation log flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: log description: Show the operation log flags: -h, --help: Print help (see more with '--help') -l, --limit=: Limit number of operations to show --no-graph: Don't show the graph, show a flat list of operations -T, --template=: Render each operation using the given template completion: flag: repository: - $directories - name: undo description: Create a new operation that undoes an earlier operation flags: -h, --help: Print help (see more with '--help') --what=*: What portions of the local state to restore (can be repeated) completion: flag: repository: - $directories what: - "repo\tThe jj repo state and local branches" - "remote-tracking\tThe remote-tracking branches. Do not restore these if you'd like to push after the undo" positional: - [] - name: restore description: Create a new operation that restores the repo to an earlier state flags: -h, --help: Print help (see more with '--help') --what=*: What portions of the local state to restore (can be repeated) completion: flag: repository: - $directories what: - "repo\tThe jj repo state and local branches" - "remote-tracking\tThe remote-tracking branches. Do not restore these if you'd like to push after the undo" positional: - [] - name: help description: Print this message or the help of the given subcommand(s) commands: - name: log description: Show the operation log - name: undo description: Create a new operation that undoes an earlier operation - name: restore description: Create a new operation that restores the repo to an earlier state - name: help description: Print this message or the help of the given subcommand(s) - name: prev description: Move the working copy commit to the parent of the current revision. flags: --edit: Edit the parent directly, instead of moving the working-copy commit -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positional: - [] - name: rebase description: Move revisions to different parent(s) flags: -b, --branch=*: Rebase the whole branch relative to destination's ancestors (can be repeated) -d, --destination!=*: The revision(s) to rebase onto (can be repeated to create a merge commit) -h, --help: Print help (see more with '--help') -r, --revision=: Rebase only this revision, rebasing descendants onto this revision's parent(s) -s, --source=*: Rebase specified revision(s) together their tree of descendants (can be repeated) completion: flag: repository: - $directories - name: resolve description: Resolve a conflicted file with an external merge tool flags: -h, --help: Print help (see more with '--help') -l, --list: Instead of resolving one conflict, list all the conflicts -q, --quiet: Do not print the list of remaining conflicts (if any) after resolving a conflict -r, --revision=: '' completion: flag: repository: - $directories positionalany: - $files - name: restore description: Restore paths from another revision flags: -c, --changes-in=: Undo the changes in a revision as compared to the merge of its parents --from=: Revision to restore from (source) -h, --help: Print help (see more with '--help') --to=: Revision to restore into (destination) completion: flag: repository: - $directories positionalany: - $files - name: show description: Show commit description and changes in a revision flags: --color-words: Show a word-level diff with changes indicated only by color --git: Show a Git-format diff -h, --help: Print help (see more with '--help') --stat: Show a histogram of the changes -s, --summary: For each path, show only whether it was modified, added, or removed --tool=: Generate diff by external command --types: For each path, show only its type before and after completion: flag: repository: - $directories positional: - [] - name: sparse description: Manage which paths from the working-copy commit are present in the working copy flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: list description: List the patterns that are currently present in the working copy flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: set description: Update the patterns that are present in the working copy flags: --add=*: Patterns to add to the working copy --clear: Include no files in the working copy (combine with --add) --edit: Edit patterns with $EDITOR -h, --help: Print help (see more with '--help') --remove=*: Patterns to remove from the working copy --reset: Include all files in the working copy completion: flag: add: - $files remove: - $files repository: - $directories - name: help description: Print this message or the help of the given subcommand(s) commands: - name: list description: List the patterns that are currently present in the working copy - name: set description: Update the patterns that are present in the working copy - name: help description: Print this message or the help of the given subcommand(s) - name: split description: Split a revision in two flags: -h, --help: Print help (see more with '--help') -i, --interactive: Interactively choose which parts to split. This is the default if no paths are provided -r, --revision=: The revision to split completion: flag: repository: - $directories positionalany: - $files - name: squash aliases: - amend description: Move changes from a revision into its parent flags: -h, --help: Print help (see more with '--help') -i, --interactive: Interactively choose which parts to squash -m, --message=*: The description to use for squashed revision (don't open editor) -r, --revision=: '' completion: flag: repository: - $directories positionalany: - $files - name: status aliases: - st description: Show high-level repo status flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: util description: Infrequently used commands such as for generating shell completions flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: completion description: Print a command-line-completion script flags: --bash: Print a completion script for Bash --fish: Print a completion script for Fish -h, --help: Print help (see more with '--help') --zsh: Print a completion script for Zsh completion: flag: repository: - $directories - name: mangen description: Print a ROFF (manpage) flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: config-schema description: Print the JSON schema for the jj TOML config format flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: help description: Print this message or the help of the given subcommand(s) commands: - name: completion description: Print a command-line-completion script - name: mangen description: Print a ROFF (manpage) - name: config-schema description: Print the JSON schema for the jj TOML config format - name: help description: Print this message or the help of the given subcommand(s) - name: undo description: Undo an operation (shortcut for `jj op undo`) flags: -h, --help: Print help (see more with '--help') --what=*: What portions of the local state to restore (can be repeated) completion: flag: repository: - $directories what: - "repo\tThe jj repo state and local branches" - "remote-tracking\tThe remote-tracking branches. Do not restore these if you'd like to push after the undo" positional: - [] - name: unsquash aliases: - unamend description: Move changes from a revision's parent into the revision flags: -h, --help: Print help (see more with '--help') -i, --interactive: Interactively choose which parts to unsquash -r, --revision=: '' completion: flag: repository: - $directories - name: untrack description: Stop tracking specified paths in the working copy flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories positionalany: - $files - name: version description: Display version information flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: workspace description: Commands for working with workspaces flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories commands: - name: add description: Add a workspace flags: -h, --help: Print help (see more with '--help') --name=: A name for the workspace -r, --revision=: The revision that the workspace should be created at; a new working copy commit will be created on top of it completion: flag: repository: - $directories positional: - [] - name: forget description: Stop tracking a workspace's working-copy commit in the repo flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: list description: List workspaces flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: root description: Show the current workspace root directory flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: update-stale description: Update a workspace that has become stale flags: -h, --help: Print help (see more with '--help') completion: flag: repository: - $directories - name: help description: Print this message or the help of the given subcommand(s) commands: - name: add description: Add a workspace - name: forget description: Stop tracking a workspace's working-copy commit in the repo - name: list description: List workspaces - name: root description: Show the current workspace root directory - name: update-stale description: Update a workspace that has become stale - name: help description: Print this message or the help of the given subcommand(s) - name: help description: Print this message or the help of the given subcommand(s) commands: - name: abandon description: Abandon a revision - name: backout description: Apply the reverse of a revision on top of another revision - name: branch description: Manage branches commands: - name: create description: Create a new branch - name: delete description: Delete an existing branch and propagate the deletion to remotes on the next push - name: forget description: Forget everything about a branch, including its local and remote targets - name: list description: List branches and their targets - name: set description: Update a given branch to point to a certain commit - name: track description: Start tracking given remote branches - name: untrack description: Stop tracking given remote branches - name: cat description: Print contents of a file in a revision - name: checkout description: Create a new, empty change and edit it in the working copy - name: chmod description: Sets or removes the executable bit for paths in the repo - name: commit description: Update the description and create a new change on top - name: config description: Manage config options commands: - name: list description: List variables set in config file, along with their values - name: get description: Get the value of a given config option. - name: set description: Update config file to set the given option to a given value - name: edit description: Start an editor on a jj config file - name: describe description: Update the change description or other metadata - name: diff description: '' - name: diffedit description: Touch up the content changes in a revision with a diff editor - name: duplicate description: Create a new change with the same content as an existing one - name: edit description: Edit a commit in the working copy - name: files description: List files in a revision - name: git description: Commands for working with the underlying Git repo commands: - name: remote description: Manage Git remotes commands: - name: add description: Add a Git remote - name: remove description: Remove a Git remote and forget its branches - name: rename description: Rename a Git remote - name: list description: List Git remotes - name: fetch description: Fetch from a Git remote - name: clone description: Create a new repo backed by a clone of a Git repo - name: push description: Push to a Git remote - name: import description: Update repo with changes made in the underlying Git repo - name: export description: Update the underlying Git repo with changes made in the repo - name: init description: Create a new repo in the given directory - name: interdiff description: Compare the changes of two commits - name: log description: Show commit history - name: merge description: Merge work from multiple branches - name: move description: Move changes from one revision into another - name: new description: Create a new, empty change and edit it in the working copy - name: next description: |- Move the current working copy commit to the next child revision in the repository. - name: obslog description: Show how a change has evolved - name: operation description: Commands for working with the operation log commands: - name: log description: Show the operation log - name: undo description: Create a new operation that undoes an earlier operation - name: restore description: Create a new operation that restores the repo to an earlier state - name: prev description: Move the working copy commit to the parent of the current revision. - name: rebase description: Move revisions to different parent(s) - name: resolve description: Resolve a conflicted file with an external merge tool - name: restore description: Restore paths from another revision - name: show description: Show commit description and changes in a revision - name: sparse description: Manage which paths from the working-copy commit are present in the working copy commands: - name: list description: List the patterns that are currently present in the working copy - name: set description: Update the patterns that are present in the working copy - name: split description: Split a revision in two - name: squash description: Move changes from a revision into its parent - name: status description: Show high-level repo status - name: util description: Infrequently used commands such as for generating shell completions commands: - name: completion description: Print a command-line-completion script - name: mangen description: Print a ROFF (manpage) - name: config-schema description: Print the JSON schema for the jj TOML config format - name: undo description: Undo an operation (shortcut for `jj op undo`) - name: unsquash description: Move changes from a revision's parent into the revision - name: untrack description: Stop tracking specified paths in the working copy - name: version description: Display version information - name: workspace description: Commands for working with workspaces commands: - name: add description: Add a workspace - name: forget description: Stop tracking a workspace's working-copy commit in the repo - name: list description: List workspaces - name: root description: Show the current workspace root directory - name: update-stale description: Update a workspace that has become stale - name: help description: Print this message or the help of the given subcommand(s) ```
rsteube commented 12 months ago

Tracking progress in https://github.com/rsteube/carapace-bin/issues/1970

rsteube commented 12 months ago

Looks really interesting, think I'll play a bit with it as well. Was looking for an alternate git client anyway.