Giter Site home page Giter Site logo

plz-cli's Introduction

Copilot, for your terminal

A CLI tool that generates shell scripts from a human readable description.

Installation

You can install plz by running the following command in your terminal.

curl -fsSL https://raw.githubusercontent.com/m1guelpf/plz-cli/main/install.sh | sh -

Homebrew

You can also install plz using Homebrew.

$ brew install plz-cli

You may need to close and reopen your terminal after installation. Alternatively, you can download the binary corresponding to your OS from the latest release.

Usage

plz uses GPT-3. To use it, you'll need to grab an API key from your dashboard, and save it to OPENAI_API_KEY as follows (you can also save it in your bash/zsh profile for persistance between sessions).

export OPENAI_API_KEY='sk-XXXXXXXX'

Once you have configured your environment, run plz followed by whatever it is that you want to do (plz show me all options for the plz cli).

To get a full overview of all available options, run plz --help

$ plz --help
Generates bash scripts from the command line

Usage: plz [OPTIONS] <PROMPT>

Arguments:
  <PROMPT>  Description of the command to execute

Options:
  -y, --force    Run the generated program without asking for confirmation
  -h, --help     Print help information
  -V, --version  Print version information

Develop

Make sure you have the latest version of rust installed (use rustup). Then, you can build the project by running cargo build, and run it with cargo run.

License

This project is open-sourced under the MIT license. See the License file for more information.

plz-cli's People

Contributors

aiellochan avatar chenrui333 avatar culda avatar hill avatar juan-leon avatar m1guelpf avatar ndbroadbent avatar soerface avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plz-cli's Issues

Request: Don't require quotes around the prompt

Would it be possible to accept multiple CLI arguments and join them together? Needing to wrap the prompt in quotes is a little bit annoying, and it would be nice to just type plz and then keep typing the prompt without quotes. E.g. plz checkout main instead of plz 'checkout main'.

Another thing that would be nice is to run the generated program by just pressing "enter" (instead of needing to press "y".) Cancelling can be done with Ctrl+C or by pressing "n", so it would be nice to default to "y"

Homebrew commands are out of date

When I asked the plz-cli to install docker on my mac, it threw the following error:

❯ plz install docker
✔ Got some code!
────────────────────────────────────────────────────────────────────────────────
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# install docker
brew cask install docker

# start docker
open /Applications/Docker.app
────────────────────────────────────────────────────────────────────────────────
>> Run the generated program? [Y/n] y
✖ The program threw an error.
Error: The Ruby Homebrew installer is now disabled and has been rewritten in
Bash. Please migrate to the following command:
  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Error: `brew cask` is no longer a `brew` command. Use `brew <command> --cask` instead.
The file /Applications/Docker.app does not exist.

The install command for homebrew is out of date. Further, the brew commands need to be updated to remove the "cask" arguments as those are deprecated.

More info for error "Failed to get a response. Have you set the OPENAI_API_KEY variable?"

Hi, looking forward to trying this, getting an error though and I'm not sure how to debug it.

The key is freshly made from https://beta.openai.com/account/api-keys.
I'm using fish shell 3.5.1 in MacOS.

 ❯ echo $OPENAI_API_KEY
sk-<key hidden>
 ❯ plz "list files"
✖ Failed to get a response. Have you set the OPENAI_API_KEY variable?

I've yet to try to code in Rust so I'm not set up to try to modify the source and see what's happening.

Support for newer versions of the API?

Would it be possible to make plz use the new chatgpt api and also add support to switch to gtp-4 once people gets access to it?

Thanks for your work!

Retry on Error

It should not be hard to capture errors in a text file, and allow additional user feedback to try again.

Proposal: store OpenAI API key securely

I think that exposing secrets such as API keys to persistant shell variables is not safe.

One solution is to add this alias-like function to .bashrc/.zshrc

# API key is in the global scope only during this command's execution
function pls() { # called "pls" so that it does not clash with "plz"
  export OPENAI_API_KEY=$(<~/.openai_api_key)  # API key is stored in a separate file
  plz $1
  unset OPENAI_API_KEY
}

The other solution is to implement safe storage and retrieval in "plz" itself. Maybe using an OS native solution like "keychain" in OSX.
But I feel like this is too much to ask for.

Sadly I am unfamiliar with rust. So, I can't contribute right away.

Error installing on Ubuntu 20.04

I got his error:

ubuntu@sol:~$ curl -fsSL https://raw.githubusercontent.com/m1guelpf/plz-cli/main/install.sh | sh - sh: 26: [[: not found https://github.com/m1guelpf/plz-cli/releases/latest/download/plz-linux-x86_64 downloading latest binary % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 13.2M 100 13.2M 0 0 10.2M 0 0:00:01 0:00:01 --:--:-- 10.2M /home/ubuntu/.bin/plz: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.32' not found (required by /home/ubuntu/.bin/plz)
/home/ubuntu/.bin/plz: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.33' not found (required by /home/ubuntu/.bin/plz) /home/ubuntu/.bin/plz: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.34' not found (required by /home/ubuntu/.bin/plz)
installed -`

Any suggestion?

Upgrade deprecated `text-davinci-003` model

Please look into updating the reference to model used. Currently configured model is deprecated. Ideally we can choose which model to use with a flag, but with set default. Cheers.

Request: Make plz aware of the current OS

Make it aware of the OS, so that it knows how to install programs on Linux vs Mac, etc. Example I ran into:

$ plz 'install cowsay'
✔ Got some code!
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
sudo apt-get install cowsay
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>> Run the generated program? [Y/n]
✖ The program threw an error.
sudo: apt-get: command not found

$ plz 'install cowsay on mac'
✔ Got some code!
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
brew install cowsay
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>> Run the generated program? [Y/n]
✔ Command ran successfully
==> Fetching cowsay
...

It would be cool to add a prefix to the prompt that tells it I'm on a Mac or Linux

Fix build scripts on Linux

Trying to use plz on Ubuntu WSL.
During the installation, the same error occurred.

"error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory"

Temp files

Why is a temporary file being made when you could just make a file only if the user asks for it. If you want to run a bash script and have the code you could do

bash -c "echo hi"

in rust it would be

Command::new("bash")
            .arg("-c")
            .arg(my_cool_code_variable)

This supports everything a bash script would allow just make sure its all as one argument.

Doesnt work on Linux aarch64

I'm running Linux raspberrypi 5.15.84-v8+ on a raspberry pi 400 and i manged to get it to build but it can't seem to get a response from openai.

Im not a rust dev so not sure what the problem is.
Ive checked in gdb and my OPENAI_API_KEY is set fine.

And curl connections work fine, maybe an issue with reqwest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.