Documentation ¶
Overview ¶
Package stdflag contains standard command-line flag code for c4t binaries.
Index ¶
- Constants
- Variables
- func C4fRunnerCliFlags() []c.Flag
- func C4fRunnerFromCli(ctx *c.Context, errw io.Writer) *c4f.Runner
- func CPUProfileCliFlag() c.Flag
- func CPUProfileFromCli(ctx *c.Context) string
- func ConfFileCliFlag() c.Flag
- func ConfigFromCli(ctx *c.Context) (*config.Config, error)
- func CorpusSizeCliFlag() c.Flag
- func CorpusSizeFromCli(ctx *c.Context) int
- func GlobalTimeoutCliFlag() c.Flag
- func GlobalTimeoutFromCli(ctx *c.Context) quantity.Timeout
- func MachArgs(dir string, qs quantity.MachNodeSet) []string
- func MachCliFlags() []c.Flag
- func MachInvocation(dir string, qs quantity.MachNodeSet) []string
- func MachNodeQuantitySetFromCli(ctx *c.Context) quantity.MachNodeSet
- func OutDirCliFlag(defaultdir string) c.Flag
- func OutDirFromCli(ctx *c.Context) string
- func PlanFileFromCli(ctx *c.Context) (string, error)
- func RootQuantitiesFromCli(ctx *c.Context) quantity.RootSet
- func RootQuantityCliFlags() []c.Flag
- func SetCommonAppSettings(a *c.App, outw, errw io.Writer) *c.App
- func SetPlanAppSettings(a *c.App, outw, errw io.Writer) *c.App
- func SubjectFuzzesCliFlag() c.Flag
- func SubjectFuzzesFromCli(ctx *c.Context) int
- func TabulatorCliFlags() []c.Flag
- func TabulatorFromCli(ctx *c.Context, w io.Writer) tabulator.Tabulator
- func Verbose(ctx *c.Context) bool
- func VerboseFlag() c.Flag
- func WorkerCountCliFlag() c.Flag
- func WorkerCountFromCli(ctx *c.Context) int
Examples ¶
Constants ¶
const ( // FlagCompiler is a standard flag for compiler selection arguments. FlagCompiler = "c" // FlagOutDir is a short flag for specifying an output directory. FlagOutDir = "d" // FlagWorkerCount is a standard flag for arguments that set a worker count. FlagWorkerCount = "j" // FlagMachine is a standard flag for machine selection arguments. FlagMachine = "m" // FlagNum is a standard flag for 'number of' arguments. FlagNum = "n" // FlagCompilerTimeout is a short flag for compiler timeout. FlagCompilerTimeout = "t" // FlagConfigFile is a standard flag for overriding the config file. FlagConfigFile = "C" // FlagAltWorkerCount is a flag for arguments that set a secondary worker count. FlagAltWorkerCount = "J" // FlagRunTimeout is a short flag for run timeout. FlagRunTimeout = "T" // FlagCPUProfile is a standard flag for specifying a CPU profile output. FlagCPUProfile = "cpuprofile" )
const ( // FlagCompilerTimeoutLong is a long flag for compiler timeout. FlagCompilerTimeoutLong = "compiler-timeout" // FlagRunTimeoutLong is a long flag for run timeout. FlagRunTimeoutLong = "run-timeout" // FlagWorkerCountLong is a long flag for arguments that set a worker count. FlagWorkerCountLong = "num-workers" // FlagCompilerWorkerCountLong is a long flag for arguments that set a compiler worker count. FlagCompilerWorkerCountLong = "num-compiler-workers" // FlagRunWorkerCountLong is a long flag for arguments that set a runner worker count. FlagRunWorkerCountLong = "num-run-workers" )
const ( // FlagOutputCsv is a flag for selecting the CSV tabulator. FlagOutputCsv = "output-csv" // UsageOutputCsv is the usage for the output-CSV flag. UsageOutputCsv = "output tables as CSV" )
const MachBinName = "c4t-mach"
MachBinName is the name of the machine node binary.
Variables ¶
var ErrBadPlanArguments = errors.New("expected plan file argument")
ErrBadPlanArguments occurs when we expect a plan file argument, but get something else.
Functions ¶
func C4fRunnerCliFlags ¶
C4fRunnerCliFlags gets the 'cli' flags needed to set up a c4f runner.
func C4fRunnerFromCli ¶
C4fRunnerFromCli makes a c4f runner using the flags previously set up by C4fRunnerCliFlags.
func CPUProfileCliFlag ¶
CPUProfileCliFlag sets up a 'cpu profile dumper' flag.
func CPUProfileFromCli ¶
CPUProfileFromCli retrieves the 'cpu profile dumper' set up by CPUProfileCliFlag.
func ConfFileCliFlag ¶
ConfFileCliFlag creates a cli flag for the config file.
func ConfigFromCli ¶
ConfigFromCli sets up a Config using the file flag set up by ConfFileCliFlag.
func CorpusSizeCliFlag ¶
CorpusSizeCliFlag sets up a 'target corpus size' flag.
func CorpusSizeFromCli ¶
CorpusSizeFromCli retrieves a plan file using the file flag set up by CorpusSizeCliFlag.
func GlobalTimeoutCliFlag ¶
GlobalTimeoutCliFlag sets up a CLI flag for global timeouts.
func GlobalTimeoutFromCli ¶
GlobalTimeoutFromCli retrieves any global timeout specified on the command line in ctx.
func MachArgs ¶
func MachArgs(dir string, qs quantity.MachNodeSet) []string
MachArgs is the arguments for an invocation of c4t-mach, given directory dir and the config uc.
Example ¶
ExampleMachArgs is a testable example for MachArgs.
package main import ( "fmt" "strings" "time" "github.com/c4-project/c4t/internal/quantity" "github.com/c4-project/c4t/internal/ux/stdflag" ) func main() { qempty := quantity.MachNodeSet{} fmt.Println(strings.Join(stdflag.MachArgs("", qempty), ", ")) qi := quantity.MachNodeSet{ Compiler: quantity.BatchSet{ Timeout: quantity.Timeout(10 * time.Second), NWorkers: 10, }, Runner: quantity.BatchSet{ Timeout: quantity.Timeout(5 * time.Minute), NWorkers: 20, }, } fmt.Println(strings.Join(stdflag.MachArgs("foo", qi), ", ")) }
Output: -d, , -compiler-timeout, 0s, -run-timeout, 0s, -num-compiler-workers, 0, -num-run-workers, 0 -d, foo, -compiler-timeout, 10s, -run-timeout, 5m0s, -num-compiler-workers, 10, -num-run-workers, 20
func MachCliFlags ¶
MachCliFlags gets the cli flags for setting up the 'user config' part of a mach or invoker invocation.
func MachInvocation ¶
func MachInvocation(dir string, qs quantity.MachNodeSet) []string
MachInvocation gets the invocation for the local-machine binary as a string list.
func MachNodeQuantitySetFromCli ¶
func MachNodeQuantitySetFromCli(ctx *c.Context) quantity.MachNodeSet
MachNodeQuantitySetFromCli gets the machine node quantity set from the flags in ctx.
func OutDirCliFlag ¶
OutDirCliFlag sets up an 'output directory' cli flag.
func OutDirFromCli ¶
OutDirFromCli gets the output directory set up by OutDirCliFlag.
func PlanFileFromCli ¶
PlanFileFromCli retrieves a plan file (which may be empty) from the arguments of ctx. Its corresponding setup function is SetupPlanAppSettings; there is no 'plan file' flag.
func RootQuantitiesFromCli ¶
RootQuantitiesFromCli gets from ctx the root-level quantity overrides specified by the user.
func RootQuantityCliFlags ¶
RootQuantityCliFlags sets up the root quantity override flags read by RootQuantitiesFromCli.
func SetCommonAppSettings ¶
SetCommonAppSettings sets app settings on a that are common to all c4t endpoints. It passes through the pointer a.
func SetPlanAppSettings ¶
SetPlanAppSettings sets app settings on a that are common to c4t endpoints handling a plan. It passes through the pointer a.
func SubjectFuzzesCliFlag ¶
SubjectFuzzesCliFlag sets up a 'number of cycles' flag.
func SubjectFuzzesFromCli ¶
SubjectFuzzesFromCli retrieves a plan file using the file flag set up by SubjectFuzzesCliFlag.
func TabulatorCliFlags ¶
TabulatorCliFlags expands into the flag set for configuring TabulatorFromCli.
func TabulatorFromCli ¶
TabulatorFromCli constructs a Tabulator that corresponds to the flags set in ctx.
There is only one format choice at the moment (CSV vs tab), but this may change in future.
func WorkerCountCliFlag ¶
WorkerCountCliFlag sets up a worker count flag.
func WorkerCountFromCli ¶
WorkerCountFromCli retrieves a 'worker count' flag set up by WorkerCountCliFlag.
Types ¶
This section is empty.