cli

package
v0.0.0-...-3948e75 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package cli provides utilities for building subcommand-based command line interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenInput

func OpenInput(filename string) (string, io.ReadCloser, error)

OpenInput is a convenience for possibly opening an input file, or otherwise returning standard in.

func OpenOutput

func OpenOutput(filename string) (string, io.WriteCloser, error)

OpenOutput is a convenience for possibly opening an output file, or otherwise returning standard out.

Types

type Command

type Command struct {
	Log *log.Logger
}

Command is a base for all subcommands.

func NewBaseCommand

func NewBaseCommand(name string) Command

NewBaseCommand builds a new base command for the named tool.

func (Command) Error

func (c Command) Error(err error) subcommands.ExitStatus

Error logs err and returns a failing exit code.

func (Command) Fail

func (c Command) Fail(format string, args ...interface{}) subcommands.ExitStatus

Fail logs an error message and returns a failing exit code.

func (Command) SetFlags

func (Command) SetFlags(f *flag.FlagSet)

SetFlags is a stub implementation of the SetFlags methods that does nothing.

func (Command) UsageError

func (c Command) UsageError(format string, args ...interface{}) subcommands.ExitStatus

UsageError logs a usage error and returns a suitable exit code.

Jump to

Keyboard shortcuts

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