cli

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AppName = "pkgdmp"

AppName is the name of the CLI application.

Variables

View Source
var (
	// ErrNoDirs is returned by [ParseFlags] if args contain no directories.
	ErrNoDirs = errors.New("no directories in command line arguments")

	// ErrVersion is returned by [ParseFlags] if the -version flag is specified.
	ErrVersion = errors.New("version")
)

Functions

func BuildCommit

func BuildCommit() string

BuildCommit returns the git commit hash pkgdmp was built from.

Returns `HEAD` if no build commit is set.

func BuildGoVersion

func BuildGoVersion() string

BuildGoVersion returns the go version pkgdmp was built with.

Returns version from runtime.Version if not set.

func BuildTime

func BuildTime() string

BuildTime returns the UTC time pkgdmp was built.

Returns current time in UTC if not set.

func ParserOptsFromCfg

func ParserOptsFromCfg(cfg *Config) ([]pkgdmp.ParserOption, error)

ParserOptsFromCfg constructs parser options from CLI configuration.

func Version

func Version() string

Version of pkgdmp.

Returns `0.0.0-dev` if no version is set.

Types

type Config

type Config struct {
	ExcludePackages string
	Only            string
	ExcludeMatching string
	Theme           string
	Matching        string
	OnlyPackages    string
	Exclude         string
	Dirs            []string `env:"skip"`
	NoDocs          bool
	NoTags          bool
	NoHighlight     bool
	FullDocs        bool
	Unexported      bool
	Version         bool `env:"skip"`
	NoEnv           bool `env:"skip"`
	JSON            bool
	// contains filtered or unexported fields
}

Config represents CLI configuration from flags.

func ParseFlags

func ParseFlags(args []string, output io.Writer) (*Config, int, error)

ParseFlags parses command line arguments as flags and returns a CLI configuration together with exit code to use if error is also returned.

func (*Config) IncludePackage added in v0.3.0

func (c *Config) IncludePackage(name string) bool

IncludePackage returns true if package with provided name should be included in the report according to configuration, or false otherwise.

Jump to

Keyboard shortcuts

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