Skip to content
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

[FEAT]: For gh copilot suggest, add a flag to send only the suggested command to stdout #37

Open
howlowck opened this issue Mar 8, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@howlowck
Copy link

howlowck commented Mar 8, 2024

Describe the need

I would like a way for the copilot cli suggest command to send only the suggested command to stdout, and then terminate the process, instead of being asked to copy the command to the clipboard.

Eliminating the user interaction and sending the suggestion to stdout would also make it more programmable.

Version

Do these docs apply to a specific version?
currently using version 0.5.4-beta (2024-01-04), but should apply to all versions

Relevant terminal output

Instead of...

❯ gh copilot suggest -t shell "get pokemon id 3 information from pokemon api and pipe it to jq to get the name"

Welcome to GitHub Copilot in the CLI!
version 0.5.4-beta (2024-01-04)

I'm powered by AI, so surprises and mistakes are possible. Make sure to verify any generated code or suggestions, and share feedback so that we can learn and improve. For more information, see https://gh.io/gh-copilot-transparency

Suggestion:

  curl -s "https://pokeapi.co/api/v2/pokemon/3" | jq '.name'

? Select an option
> Copy command to clipboard

Command copied to clipboard!

? Select an option  [Use arrows to move, type to filter]
> Copy command to clipboard
  Explain command
  Revise command
  Rate response
  Exit

It would just be...

❯ gh copilot suggest -t shell --non-interactive "get pokemon id 3 information from pokemon api and pipe it to jq to get the name"

curl -s "https://pokeapi.co/api/v2/pokemon/3" | jq '.name'
@howlowck howlowck added enhancement New feature or request needs-triage needs to be reviewed labels Mar 8, 2024
@howlowck howlowck changed the title [FEAT]: (for gh copilot suggest) Add a flag to send **only** the suggested command to stdout [FEAT]: For gh copilot suggest, add a flag to send only the suggested command to stdout Mar 8, 2024
@howlowck
Copy link
Author

howlowck commented Mar 8, 2024

Going through the open issues.. I think the proposed solution in this issue can be a middle ground between forcing user interaction and issue #2 (have copilot execute the suggested code). It would effectively put the onus on the user to use the resulting command however they see fit; they can pipe the result to execute it or to save it to a file. It's up to the user.

@andyfeller
Copy link
Contributor

andyfeller commented Mar 21, 2024

Thanks for opening up this issue, @howlowck!

I would like a way for the copilot cli suggest command to send only the suggested command to stdout, and then terminate the process, instead of being asked to copy the command to the clipboard.

Eliminating the user interaction and sending the suggestion to stdout would also make it more programmable.

What are some use cases you are considering for making gh copilot more programmable? What are your thoughts about situations where Copilot might not be able to give you an answer?

@andyfeller andyfeller removed the needs-triage needs to be reviewed label Mar 21, 2024
@rlove
Copy link

rlove commented Mar 21, 2024

Another idea is that is similar is too. Add --copy flag so all you have to do is paste after it has run, reducing input required and --copy I would just put into my ghcs and ghce aliases so I can have it always behave that way.

@andyfeller
Copy link
Contributor

andyfeller commented Mar 21, 2024

Another idea is that is similar is too. Add --copy flag so all you have to do is paste after it has run, reducing input required and --copy I would just put into my ghcs and ghce aliases so I can have it always behave that way.

Thanks for beating me to the punch, @rlove, and already upgrading to v1.0.0! ✨ So a few things I was thinking about regarding this issue up to GA:

ghcs works like the technical preview of executing commands in the context of the shell that invoked the experience using the gh copilot suggest --shell-out flag. Everything about gh copilot outputs to stdout, it's how most CLIs work, so you could use this flag.

All of that said, GitHub Copilot in the CLI is not currently designed for or intended to be used in an automated fashion as being discussed. Ideally there would be a Copilot SDK or library for people who want to build an automated experience. The challenge is that most conversational chat involves human interaction and multiple rounds of revision.

@nickmccurdy
Copy link

nickmccurdy commented Mar 22, 2024

Please add this, since I can't execute commands in Fish, this would at least let me pipe the command into my shell.

@mendhak
Copy link

mendhak commented Mar 27, 2024

I'm interested in just the first part, getting the suggestion, but not necessarily the programmable part. I hope that programmability aspect isn't a reason that this suggestion is ignored.

Being able to only get the suggested command has useful productivity aspects, it's a quick lookup helper that gets out of your way.

More often than not I'd like to use Copilot CLI to just get the suggestion and use that as a jumping-off point. I don't really need a perfectly precise result, it is after all just a suggestion.

$ gh copilot suggest --non-interactive -t shell "How do I get all the ECS Fargate tasks running in a cluster?"
<blah blah blah> 
aws ecs list-tasks --cluster <cluster-name> --launch-type FARGATE

I am currently having to get the suggestion, and then ⬇️⬇️⬇️⬇️⬇️ interactively exiting, each time I use the tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants