cmd

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	App = &cli.App{
		Name:   "goodhosts",
		Usage:  "manage your hosts file goodly",
		Action: DefaultAction,
		Commands: append(Commands(), &cli.Command{
			Name:    "version",
			Usage:   "",
			Aliases: []string{"v", "ver"},
			Action: func(c *cli.Context) error {
				logrus.Infof(version)
				return nil
			},
		}),
		Before: func(ctx *cli.Context) error {
			if ctx.Bool("debug") {
				logrus.SetLevel(logrus.DebugLevel)
				logrus.SetFormatter(&logrus.TextFormatter{})
			} else {

				logrus.SetFormatter(&easy.Formatter{
					LogFormat: "%msg%",
				})
			}
			if ctx.Bool("quiet") {
				logrus.SetOutput(io.Discard)
			}
			return nil
		},
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:    "file",
				Aliases: []string{"f"},
				Value:   "",
				Usage:   fmt.Sprintf("override the default hosts: %s", hostsfile.HostsFilePath),
			},
			&cli.BoolFlag{
				Name:    "debug",
				Aliases: []string{"d"},
				Usage:   "Turn on verbose debug logging",
			},
			&cli.BoolFlag{
				Name:    "quiet",
				Aliases: []string{"q"},
				Usage:   "Turn on off all logging",
			},
		},
	}
)

Functions

func Add

func Add() *cli.Command

func Backup

func Backup() *cli.Command

func Check

func Check() *cli.Command

func Clean added in v1.0.4

func Clean() *cli.Command

func Commands

func Commands() []*cli.Command

func Debug

func Debug() *cli.Command

func DefaultAction

func DefaultAction(c *cli.Context) error

func Edit

func Edit() *cli.Command

func List

func List() *cli.Command

func Remove

func Remove() *cli.Command

func Restore

func Restore() *cli.Command

func Version added in v1.0.6

func Version(v, c, d string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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