-
Couldn't load subscription status.
- Fork 7.3k
Add preview prompter command
#10745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add preview prompter command
#10745
Conversation
b4e6d61 to
abd573a
Compare
d7de8fb to
4615069
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new top-level "preview" command for demonstrating gh's prompting experiences in a no-op environment. Key changes include:
- Adding a new "preview" command registration to the root command.
- Implementing the "prompter" subcommand to demo various prompt types.
- Creating a dedicated command file to integrate and manage preview commands.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/cmd/root/root.go | Registers the preview command for UX demo purposes. |
| pkg/cmd/preview/prompter/prompter.go | Implements interactive demos for different prompts. |
| pkg/cmd/preview/preview.go | Sets up the preview command and integrates prompter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, @BagToad! This really helps with trying different prompt types.
|
I'm wondering if in the future we may want to add more commands like this; I mean dev/meta/instrumentation kind of commands just for maintainers' debugging/diagnostic purposes. In that case, I'd rather see all of them under a single top-level command (e.g., What do you think? |
I agree, I had commented on this in the original PR body:
It is all currently proposed under a top level I think that is a legitimate concern, but doesn't seem to collide with any public extensions currently 🤔 The extensions out there are close enough to I think @andyfeller what do you think? |
| cmd.AddCommand(statusCmd.NewCmdStatus(f, nil)) | ||
| cmd.AddCommand(codespaceCmd.NewCmdCodespace(f)) | ||
| cmd.AddCommand(projectCmd.NewCmdProject(f)) | ||
| cmd.AddCommand(previewCmd.NewCmdPreview(f)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Should there be a separate section for previews that shows each of the commands within?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I follow; are you talking about adding some whitespace here to separate cmd.AddCommand(previewCmd.NewCmdPreview(f)) from other commands?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion and the delay; let me elaborate.
Within the root command, the command groups created are turned into separate sections of the gh --help output:
Lines 111 to 122 in 7ceca45
| cmd.AddGroup(&cobra.Group{ | |
| ID: "core", | |
| Title: "Core commands", | |
| }) | |
| cmd.AddGroup(&cobra.Group{ | |
| ID: "actions", | |
| Title: "GitHub Actions commands", | |
| }) | |
| cmd.AddGroup(&cobra.Group{ | |
| ID: "extension", | |
| Title: "Extension commands", | |
| }) |
Expand for gh --help example
$ gh --help
Work seamlessly with GitHub from the command line.
USAGE
gh <command> <subcommand> [flags]
CORE COMMANDS
auth: Authenticate gh and git with GitHub
browse: Open repositories, issues, pull requests, and more in the browser
codespace: Connect to and manage codespaces
gist: Manage gists
issue: Manage issues
org: Manage organizations
pr: Manage pull requests
project: Work with GitHub Projects.
release: Manage releases
repo: Manage repositories
GITHUB ACTIONS COMMANDS
cache: Manage GitHub Actions caches
run: View details about workflow runs
workflow: View details about GitHub Actions workflows
EXTENSION COMMANDS
XXXXXXX: Extension xxxx
XXXXXXXXXX: Extension xxxx
...
ALIAS COMMANDS
xxxxxx: Alias for "xxx"
...
ADDITIONAL COMMANDS
alias: Create command shortcuts
api: Make an authenticated GitHub API request
attestation: Work with artifact attestations
completion: Generate shell completion scripts
config: Manage configuration for gh
extension: Manage gh extensions
gpg-key: Manage GPG keys
label: Manage labels
ruleset: View info about repo rulesets
search: Search for repositories, issues, and pull requests
secret: Manage GitHub secrets
ssh-key: Manage SSH keys
status: Print information about relevant issues, pull requests, and notifications across repositories
variable: Manage GitHub Actions variablesThis is handled deep in the bowels of gh:
Lines 136 to 151 in 7ceca45
| // Statically calculated padding for non-extension commands, | |
| // longest is `gh accessibility` with 13 characters + 1 space. | |
| // | |
| // Should consider novel way to calculate this in the future [AF] | |
| namePadding := 14 | |
| for _, g := range GroupedCommands(command) { | |
| var names []string | |
| for _, c := range g.Commands { | |
| names = append(names, rpad(c.Name()+":", namePadding)+c.Short) | |
| } | |
| helpEntries = append(helpEntries, helpEntry{ | |
| Title: strings.ToUpper(g.Title), | |
| Body: strings.Join(names, "\n"), | |
| }) | |
| } |
So, the suggestion was whether we should have a separate command group for preview commands or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PREVIEW COMMANDS
prompter: Execute a test program to preview the prompterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point actually. I like the separate group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I got to implementing this and realized all the commands in gh --help are top level commands.
Like gh run and gh workflow, for example.
But in this case, only preview is our top-level command.
Referring back to the suggested output:
PREVIEW COMMANDS
prompter: Execute a test program to preview the prompter
Is this confusing that, for only the preview command group, none of the commands listed under the group are top-level commands? Are users going to understand that you have to run gh preview prompter and not gh prompter?
WDYT?
Maybe we can merge this PR without this, and then decide later how we'd want that to look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😶 😬
PREVIEW COMMANDS
preview prompter: Execute a test program to preview the prompter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a fair point about users potentially being confused / missing these commands need to be gh preview.
I agree we should move forward with this PR as-is and revisit as we see how preview experiment proceeds.
Currently, preview will show up under ADDITIONAL COMMANDS section:
$ bin/gh help
Work seamlessly with GitHub from the command line.
USAGE
gh <command> <subcommand> [flags]
CORE COMMANDS
...
GITHUB ACTIONS COMMANDS
...
EXTENSION COMMANDS
...
ALIAS COMMANDS
...
ADDITIONAL COMMANDS
...
preview: Execute previews for gh features
This comment was marked as spam.
This comment was marked as spam.
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | minor | `v2.73.0` -> `v2.74.1` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>cli/cli (cli/cli)</summary> ### [`v2.74.1`](https://github.com/cli/cli/releases/tag/v2.74.1): GitHub CLI 2.74.1 [Compare Source](cli/cli@v2.74.0...v2.74.1) #### What's Changed - Document support for `@copilot` in `gh [pr|issue] edit --add-assignee` and `--remove-assignee` by [@​timrogers](https://github.com/timrogers) in cli/cli#11056 - Fix pr edit when URL is provided by [@​williammartin](https://github.com/williammartin) in cli/cli#11057 - Fix const in MR finder tests by [@​babakks](https://github.com/babakks) in cli/cli#11091 **Full Changelog**: cli/cli@v2.74.0...v2.74.1 ### [`v2.74.0`](https://github.com/cli/cli/releases/tag/v2.74.0): GitHub CLI 2.74.0 [Compare Source](cli/cli@v2.73.0...v2.74.0) #### Security A security vulnerability has been identified in a core `gh` dependency, `go-gh`, where an attacker-controlled GitHub Enterprise Server could result in executing arbitrary commands on a user's machine by replacing HTTP URLs provided by GitHub with local file paths for browsing. This issue is addressed in this `gh` release by updating `go-gh` to a fixed version. For more information, see GHSA-g9f5-x53j-h563 #### What's changed ##### ✨ Features - Add `preview prompter` command by [@​BagToad](https://github.com/BagToad) in cli/cli#10745 - \[gh run watch] Support `--compact` flag by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10629 - Fix brew update notifications by [@​BagToad](https://github.com/BagToad) in cli/cli#11024 ##### 🐛 Fixes - Revert "\[gh config] Escape pipe symbol in Long desc for website manual" by [@​BagToad](https://github.com/BagToad) in cli/cli#11004 - Fix formatting in allowed values for `gh config --help` by [@​BagToad](https://github.com/BagToad) in cli/cli#11003 - fix: `gh gist edit` panic when no file in a gist by [@​phanen](https://github.com/phanen) in cli/cli#10627 - Add retry logic when fetching TUF content in `gh attestation` commands by [@​malancas](https://github.com/malancas) in cli/cli#10943 ##### 📚 Docs & Chores - Update README.md by [@​irhdab](https://github.com/irhdab) in cli/cli#11022 - Add tests for `RenderJobs` and `RenderJobsCompact` by [@​babakks](https://github.com/babakks) in cli/cli#11013 - Add example usage of `--head` option to `pr list` docs by [@​babakks](https://github.com/babakks) in cli/cli#10979 - Mention `pr create` will print the created MR's URL by [@​babakks](https://github.com/babakks) in cli/cli#10980 - Add Digest to ReleaseAsset struct by [@​bdehamer](https://github.com/bdehamer) in cli/cli#11030 #####Dependencies - Bump `go-gh` to v2.12.1 by [@​BagToad](https://github.com/BagToad) in cli/cli#11043 - chore(deps): bump github.com/gabriel-vasile/mimetype from 1.4.8 to 1.4.9 by [@​dependabot](https://github.com/dependabot) in cli/cli#10825 - Update sigstore-go dependency to v1.0.0 by [@​malancas](https://github.com/malancas) in cli/cli#11028 - chore(deps): bump github.com/sigstore/protobuf-specs from 0.4.1 to 0.4.2 by [@​dependabot](https://github.com/dependabot) in cli/cli#10999 - chore(deps): bump github.com/yuin/goldmark from 1.7.8 to 1.7.12 by [@​dependabot](https://github.com/dependabot) in cli/cli#11032 #### New Contributors - [@​irhdab](https://github.com/irhdab) made their first contribution in cli/cli#11022 - [@​phanen](https://github.com/phanen) made their first contribution in cli/cli#10627 **Full Changelog**: cli/cli@v2.73.0...v2.74.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC41MC4wIiwidXBkYXRlZEluVmVyIjoiNDAuNTAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
This pull request proposes a new top-level
previewcommand, enabling users and maintainers to easily preview or demo core elements ofgh's UX. Currently, the only subcommand I'm proposing here isprompterto quickly run through allgh's prompting experiences in a no-op environment, but I could easily see this being useful with other features like:gh preview color: print all the colorsghuses (think of a printer's test page 😁 )gh preview progress: display whatever progress indicator you have configured for some time (either a textual one or a spinner)This is related to #10710 because I had this idea while developing the accessible prompter changes.
Demo with accessible prompter
VHS tape file...