gopilot-cli

command module
v0.0.0-...-7ac3d4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 13 Imported by: 0

README

gopilot-cli

A GitHub Copilot CLI, written in Go.

Inspired by B00TK1D/copilot-api.

Example

Disclaimer

[!IMPORTANT] This tool is not affiliated with GitHub, Microsoft or OpenAI. It might violate the GitHub Copilot terms of service - use at your own risk.

This tool requires an active GitHub Copilot subscription (10$/month for individuals).

Example

query
gopilot-cli query "How do I get the number of CPUs?"
nproc
code
gopilot-cli -l Rust -m 500 -p 0.9 code "Print the first 100 primes in the most efficient way possible"
fn is_prime(n: u64) -> bool {
    if n == 2 {
        return true;
    }

    if n < 2 || n % 2 == 0 {
        return false;
    }

    let mut i = 3;
    while i * i <= n {
        if n % i == 0 {
            return false;
        }
        i += 2;
    }

    return true;
}

fn main() {
    let mut count = 0;
    let mut i = 0;
    while count < 100 {
        if is_prime(i) {
            println!("{}", i);
            count += 1;
        }
        i += 1;
    }
}

This code defines a function to check if a number is prime and prints the first 100 prime numbers. The is_prime function checks if a number is prime by dividing it by all odd numbers up to the square root of the number. The main function iterates through numbers, checks if they are prime using is_prime, and prints them until 100 primes are found.

Installation

go install github.com/denysvitali/gopilot-cli@latest

Usage

Check gopilot-cli -h for more information or refer to the examples above.

[!TIP] You can pipe the output of the gopilot-cli code subcommand to glow to render the markdown code blocks in your terminal.

Suggested shell integrations

ktip

Provides answers to your Kubernetes questions.

ktip example

Add this to your .zshrc (or .bashrc):

function ktip(){
	gopilot-cli -l Kubernetes -m 500 -p 0.9 code "$1" | glow
}
gotip

Provides answers to your Go questions.

gotip example

Add this to your .zshrc (or .bashrc):

function gotip(){
	gopilot-cli -l Go -m 500 -p 0.9 code "$1" | glow
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL