cmd

package
v0.0.102 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cmd provides the command line interface for the guard.

Index

Constants

This section is empty.

Variables

View Source
var GuardInfoCommand = &cli.Command{
	Name:        "info",
	Description: "learn how to use guard cli",
	Action: func(c *cli.Context) error {
		fmt.Println(string(markdown.Render(help, termsize.Width(), 6)))
		return nil
	},
}

GuardInfoCommand gets info about using the guard agent.

View Source
var GuardRunCommand = &cli.Command{
	Name:        "run",
	Description: "runs the guard service",
	Flags:       []cli.Flag{configFlag},
	Action: func(c *cli.Context) error {
		guardConfig, err := config.DecodeGuardConfig(core.ExpandOrReturnPath(c.String(configFlag.Name)))
		if err != nil {
			return fmt.Errorf("failed to decode config: %w", err)
		}

		g, _ := errgroup.WithContext(c.Context)

		guard, err := guard.NewGuard(c.Context, guardConfig)
		if err != nil {
			return fmt.Errorf("failed to create guard: %w", err)
		}

		g.Go(func() error {
			err = guard.Start(c.Context)
			if err != nil {
				return fmt.Errorf("failed to run guard: %w", err)
			}

			return nil
		})

		if err := g.Wait(); err != nil {
			return fmt.Errorf("failed to run guard: %w", err)
		}

		return nil
	},
}

GuardRunCommand runs the guard.

Functions

func Start

func Start(args []string, buildInfo config.BuildInfo)

Start starts the command line.

Types

This section is empty.

Jump to

Keyboard shortcuts

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