tool

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package tool contains utilities for creating Service Weaver tools similar to weaver-multi, weaver-gke, and weaver-gke-local.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlagsHelp

func FlagsHelp(flags *flag.FlagSet) string

FlagsHelp pretty prints the set of flags in the provided FlagSet, along with their descriptions and default values. Here's an example output:

-h, --help    Print this help message.
--follow      Act like tail -f (default false)
--format      Output format (pretty or json) (default pretty)
--system      Show system internal logs (default false)

func MainHelp

func MainHelp(tool string, commands map[string]*Command) string

MainHelp returns the help message for the provided set of commands.

func Run

func Run(tool string, commands map[string]*Command)

Run executes a collection of subcommands, parsing command line arguments and dispatching to the correct subcommand.

Types

type Command

type Command struct {
	Name        string                                // subcommand name
	Description string                                // short one-line description
	Help        string                                // full help message
	Flags       *flag.FlagSet                         // flags
	Fn          func(context.Context, []string) error // passed command line args that occur after the subcommmand name
	Hidden      bool                                  // hide from help messages?
}

Command is a subcommand of a binary, like the "add" in "git add".

func LogsCmd

func LogsCmd(spec *LogsSpec) *Command

LogsCmd returns a command to query log entries.

func PurgeCmd

func PurgeCmd(spec *PurgeSpec) *Command

PurgeCmd returns a command to delete a set of paths.

type LogsSpec

type LogsSpec struct {
	Tool    string                                        // tool name, e.g., "weaver gke"
	Flags   *flag.FlagSet                                 // optional additional flags
	Rewrite func(logging.Query) (logging.Query, error)    // optional query preprocessing
	Source  func(context.Context) (logging.Source, error) // returns log source
	// contains filtered or unexported fields
}

LogSpec configures the command returned by LogsCmd.

type PurgeSpec

type PurgeSpec struct {
	Tool  string   // tool name (e.g., "weaver multi")
	Kill  string   // regex of processes to kill, or empty
	Paths []string // paths to delete
	// contains filtered or unexported fields
}

PurgeSpec configures the command returned by PurgeCmd.

Jump to

Keyboard shortcuts

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