microsoft / Codex-CLI

CLI tool that uses Codex to turn natural language commands into their Bash/ZShell/PowerShell equivalents
MIT License
1.99k stars 182 forks source link

automatically comment natural language command in PS #100

Closed codehruv closed 2 years ago

codehruv commented 2 years ago

Now we don't have to add # before every natural language command in powershell. It will be added automatically.

dluc commented 2 years ago

@codehruv should we do this for all the shells (cmd, ps, bash, zsh) and update the docs?

image
dluc commented 2 years ago

What do you think about the scenario where there is no suggestion? e.g.

  1. Type hello
  2. Press Ctrl-G
  3. The prompt changes to # hello and Codex doesn't suggest a command, so the user is left with a commented line
Vivihung commented 2 years ago

+1 for keeping it consistent between shells.

codehruv commented 2 years ago

@dluc in a separate PR, I have added code so that if the model doesn't return a response, we print a message like "# model didn't return a response"

codehruv commented 2 years ago

@dluc I wasn't going to change the docs till the change was made for bash/zsh as well. Do you think it will be possible to modify the shell buffer in bash/zsh for similar behavior?

dluc commented 2 years ago

@dluc in a separate PR, I have added code so that if the model doesn't return a response, we print a message like "# model didn't return a response"

Personally I wouldn't replace the input with an error. A similar scenario I can think of is "autocompletion", where nothing happens. E.g. if you type python-he and press Tab to autocomplete, nothing happens, and users are familiar with this behavior. If I pressed Tab and python-he was replaced with an error message, it would feel very odd.

Also I think that mentioning "model" can be confusing, it's an internal implementation detail. If we want to show an error, I would leave the original text in place, echo the error, and move to a new empty prompt, something like:

C:\> # hello  [user presses Ctrl-g]
Codex CLI could not find a suggestion
C:\>