tool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 17 Imported by: 8

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 ProfileGroups

func ProfileGroups(groups [][]func() (*protos.Profile, error)) (*protos.Profile, error)

ProfileGroups returns the approximate sum of the profiles of all members of all groups. If a group has more than one member, only a subset of the group may be profiled and the result scaled up assuming non-profiled members of the group have similar profiles. Each group member is represented by a function that profiles that group member.

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.

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.

Jump to

Keyboard shortcuts

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