cmd

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "pipegpt",
	Short: "A simple CLI tools to question chatgpt",
	Long: `pipegpt is a simple CLI tools to question chatgpt.

You can use it to question chatgpt with your pre-defined prompt or interactively (in cli manner).
pipegpt always wait for your input from stdin and output the result to stdout.
Provided prompt is used as the first input to chatgpt.

Simple Example:
# code review in staged changes
git diff --staged | pipegpt -p "code review for this change"

# commit with suggested commit message
git diff --staged  | pipegpt -p "suggest conventional commit messages for these changes" | git commit -F - -e

# convert JSON to YAML
cat sample.json | pipegpt -p "convert JSON to YAML"
`,
	Run: func(cmd *cobra.Command, args []string) {
		prompt, err := cmd.Flags().GetString("prompt")
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		role := viper.GetString("default.role")
		input := stdin.ConsumeStdin()

		client, err := createClient()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		result, err := generic.New(client).Run(role, prompt, input)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		fmt.Println(result)
	},
}

Functions

func CreateSubcommand

func CreateSubcommand(name string, definition map[string]interface{}) error

CreateSubcommand creates a subcommand

Types

This section is empty.

Jump to

Keyboard shortcuts

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