Documentation ¶
Overview ¶
Package cmd provides subcommands for the vervet CLI.
Index ¶
- Variables
- func Build(ctx *cli.Context) error
- func Generate(ctx *cli.Context) error
- func Lint(ctx *cli.Context) error
- func Localize(ctx *cli.Context) error
- func Resolve(ctx *cli.Context) error
- func ResourceFiles(ctx *cli.Context) error
- func ResourceShow(ctx *cli.Context) error
- func ScaffoldInit(ctx *cli.Context) error
- type Prompt
- type VervetApp
- type VervetParams
- type VervetPrompt
Constants ¶
This section is empty.
Variables ¶
var BuildCommand = cli.Command{ Name: "build", Usage: "Build versioned resources into versioned OpenAPI specs", ArgsUsage: "[input resources root] [output api root]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "config", Aliases: []string{"c", "conf"}, Usage: "Project configuration file", }, &cli.BoolFlag{ Name: "lint", Usage: "Enable linting during build", Value: true, }, &cli.StringFlag{ Name: "include", Aliases: []string{"I"}, Usage: "OpenAPI specification to include in build output", }, }, Action: Build, }
BuildCommand is the `vervet build` subcommand.
var CLIApp = cli.App{ Name: "vervet", Usage: "OpenAPI resource versioning tool", Version: "develop", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "debug", Usage: "Turn on debug logging", }, }, Commands: []*cli.Command{ &BuildCommand, &GenerateCommand, &LintCommand, &LocalizeCommand, &ResourceCommand, &ResolveCommand, }, }
var GenerateCommand = cli.Command{ Name: "generate", Usage: "Generate artifacts from resource versioned OpenAPI specs", ArgsUsage: "<generator> [<generator2>...]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "config", Aliases: []string{"c", "conf"}, Usage: "Project configuration file", }, &cli.BoolFlag{ Name: "dry-run", Aliases: []string{"n"}, Usage: "Dry-run, listing files that would be generated", }, &cli.StringFlag{ Name: "generators", Aliases: []string{"g", "gen", "generator"}, Usage: "Generators definition file", }, }, Action: Generate, }
GenerateCommand is the `vervet generate` subcommand.
var LintCommand = cli.Command{ Name: "lint", Usage: "Lint versioned resources", ArgsUsage: "[input resources root] [output api root]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "config", Aliases: []string{"c", "conf"}, Usage: "Project configuration file", }, }, Action: Lint, }
LintCommand is the `vervet lint` subcommand.
var LocalizeCommand = cli.Command{ Name: "localize", Aliases: []string{"localise"}, Usage: "Localize references and validate a single OpenAPI spec file", ArgsUsage: "[spec.yaml file]", Action: Localize, }
LocalizeCommand is the `vervet localize` subcommand
var ResolveCommand = cli.Command{ Name: "resolve", Usage: "Aggregate, render and validate resource specs at a particular version", ArgsUsage: "[resource root]", Flags: []cli.Flag{ &cli.StringFlag{Name: "at"}, }, Action: Resolve, }
ResolveCommand is the `vervet resolve` subcommand.
var ResourceCommand = cli.Command{ Name: "resource", Aliases: []string{"rc"}, Flags: []cli.Flag{ &cli.StringFlag{ Name: "config", Aliases: []string{"c", "conf"}, Usage: "Project configuration file", }, }, Subcommands: []*cli.Command{{ Name: "files", Usage: "List OpenAPI files of versioned resources in a vervet project", ArgsUsage: "[api [resource]]", Action: ResourceFiles, }, { Name: "info", Usage: "Information about versioned resources in a vervet project", ArgsUsage: "[api [resource]]", Action: ResourceShow, }}, }
ResourceCommand is the `vervet resource` subcommand.
var Scaffold = cli.Command{ Name: "scaffold", Subcommands: []*cli.Command{{ Name: "init", Usage: "Initialize a new project from a scaffold", ArgsUsage: "[path to scaffold directory]", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "force", Aliases: []string{"f", "overwrite"}, Usage: "Overwrite existing files", }, }, Action: ScaffoldInit, }}, }
Scaffold is the `vervet scaffold` subcommand.
var Vervet = NewApp(&CLIApp, VervetParams{ Stdin: os.Stdin, Stdout: os.Stdout, Stderr: os.Stderr, Prompt: Prompt{}, })
Vervet is the vervet application with the CLI application.
Functions ¶
func Build ¶
func Build(ctx *cli.Context) error
Build compiles versioned resources into versioned API specs.
func Generate ¶
func Generate(ctx *cli.Context) error
Generate executes code generators against OpenAPI specs.
func Lint ¶
func Lint(ctx *cli.Context) error
Lint checks versioned resources against linting rules.
func Localize ¶
func Localize(ctx *cli.Context) error
Localize references and validate a single OpenAPI spec file
func Resolve ¶
func Resolve(ctx *cli.Context) error
Resolve aggregates, renders and validates resource specs at a particular version.
func ResourceFiles ¶
func ResourceFiles(ctx *cli.Context) error
ResourceFiles is a command that lists all versioned OpenAPI spec files of matching resources. It takes optional arguments to filter the output: api resource
func ResourceShow ¶
func ResourceShow(ctx *cli.Context) error
ResourceShow is a command that lists all the versions of matching resources. It takes optional arguments to filter the output: api resource
func ScaffoldInit ¶
func ScaffoldInit(ctx *cli.Context) error
ScaffoldInit creates a new project configuration from a provided scaffold directory.
Types ¶
type Prompt ¶
type Prompt struct{}
Prompt is the default interactive prompt for vervet.
type VervetApp ¶
type VervetApp struct { App *cli.App Params VervetParams }
VervetApp contains the cli Application.
func NewApp ¶
func NewApp(app *cli.App, vp VervetParams) *VervetApp
NewApp returns a new VervetApp with the provided params.
type VervetParams ¶
type VervetParams struct { Stdin io.ReadCloser Stdout io.WriteCloser Stderr io.WriteCloser Prompt VervetPrompt }
VervetParams contains configuration parameters for the Vervet CLI application.
type VervetPrompt ¶
type VervetPrompt interface { Confirm(label string) (bool, error) // Confirm y/n an action Entry(label string) (string, error) // Gather a freeform entry in response to a question Select(label string, items []string) (string, error) // Select from a limited number of entries }
VervetPrompt defines the interface for interactive prompts in vervet.