cli

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CleanCommand *cli.Command = &cli.Command{
	Name:    string(CleanCommandName),
	Aliases: []string{"c"},
	Usage:   "Clean Git hooks scripts configured by Gookme",
	Action: func(cContext *cli.Context) error {
		return clean()
	},
}
View Source
var InitCommand *cli.Command = &cli.Command{
	Name:    string(InitCommandName),
	Aliases: []string{"i"},
	Usage:   "initialize Git hooks script files to run Gookme",
	Flags: []cli.Flag{
		&cli.StringSliceFlag{
			Name:    "types",
			Aliases: []string{"t"},
			Usage:   "The types of Git hooks to hook. Accepted values are: pre-commit, prepare-commit-msg, commit-msg,  post-commit, post-merge, post-rewrite, pre-rebase, post-checkout, pre-push",
		},
		&cli.BoolFlag{
			Name:    "all",
			Aliases: []string{"a"},
			Usage:   "Initialize all available hooks. Has precedence over the --types flag",
		},
	},
	Action: func(cContext *cli.Context) error {
		args, err := parseInitCommandArguments(cContext)
		if err != nil {
			return err
		}
		return initFn(*args)
	},
}
View Source
var RunCommand *cli.Command = &cli.Command{
	Name:    string(RunCommandName),
	Aliases: []string{"r"},
	Usage:   "load and run git hooks based on staged Git changes",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "type",
			Aliases: []string{"t"},
			Value:   "pre-commit",
			Usage:   "The type of Git hook to run. Default is pre-commit, but accepted values are: pre-commit, prepare-commit-msg, commit-msg,  post-commit, post-merge, post-rewrite, pre-rebase, post-checkout, pre-push",
		},
		&cli.StringFlag{
			Name:    "from",
			Aliases: []string{"f"},
			Usage:   "An optional commit SHA-1 hash to compare to generate the staged changes from.",
		},
		&cli.StringFlag{
			Name:    "to",
			Aliases: []string{"o"},
			Usage:   "An optional commit SHA-1 hash to compare to generate the staged changes to.",
		},
	},
	Action: func(cContext *cli.Context) error {
		args, err := parseRunCommandArguments(cContext)

		if err != nil {
			return err
		}
		return run(*args)
	},
}

Functions

func NewCLI

func NewCLI() *cli.App

Types

type CommandName

type CommandName string
const (
	CleanCommandName CommandName = "clean"
)
const (
	InitCommandName CommandName = "init"
)
const (
	RunCommandName CommandName = "run"
)

type InitCommandArguments

type InitCommandArguments struct {
	HookTypes []configuration.HookType
}

type RunCommandArguments

type RunCommandArguments struct {
	HookType       configuration.HookType
	GitCommandArgs []string
	From           string
	To             string
}

Jump to

Keyboard shortcuts

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