cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *kong.Context

New creates a new *kong.Context and returns a pointer to it. The *kong.Context is used to parse command-line arguments for the "jotbot" CLI tool.

Types

type CLI

type CLI struct {
	Generate struct {
		Root      string   `arg:"" help:"Root directory of the repository."`
		Filter    []string `name:"filter" short:"f" env:"JOTBOT_FILTER" help:"Glob pattern(s) to filter files."`
		Commit    bool     `name:"commit" default:"true" env:"JOTBOT_COMMIT" help:"Commit changes to Git."`
		Branch    string   `default:"jotbot-patch" env:"JOTBOT_BRANCH" help:"Branch name to commit changes to."`
		Limit     int      `default:"0" env:"JOTBOT_LIMIT" help:"Limit the number of documentations to generate."`
		FileLimit int      `default:"0" env:"JOTBOT_FILE_LIMIT" help:"Limit the number of files to generate documentations for."`
		DryRun    bool     `name:"dry" default:"false" env:"JOTBOT_DRY_RUN" help:"Print the changes without applying them."`
		Model     string   `default:"gpt-3.5-turbo" env:"JOTBOT_MODEL" help:"OpenAI model to use."`
		Override  bool     `name:"override" short:"o" env:"JOTBOT_OVERRIDE" help:"Override existing documentation."`
		Clear     bool     `name:"clear" short:"c" env:"JOTBOT_CLEAR" help:"Clear existing documentation."`
	} `cmd:"" default:"withargs" help:"Generate missing documentation."`

	APIKey  string `name:"key" env:"OPENAI_API_KEY" help:"OpenAI API key."`
	Verbose bool   `name:"verbose" short:"v" env:"JOTBOT_VERBOSE" help:"Enable verbose logging."`
}

CLI represents a command-line interface for generating missing documentation. It has options to configure the generation process, such as file filtering, committing changes to Git, and limiting the number of documentations generated. It also allows overriding or clearing existing documentation. The API key for OpenAI is provided as an option. Use New() to create a new CLI instance and Run() to execute it.

func (*CLI) Run

func (cfg *CLI) Run(ctx *kong.Context) error

Run generates missing documentation. It uses OpenAI's GPT to generate documentation for exported functions and types in Go source files. It takes a Kong context as an argument and returns an error if one occurred during execution.

Jump to

Keyboard shortcuts

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