ecmd

package
v2.0.0-dev0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 8 Imported by: 6

README

Docs: GoDoc

Note: this is now deprecated in favor of the econfig system, which provides a single common Config object for all configuration settings, with TOML config files and command-line arg support.

ecmd.Args provides maps for storing commandline arguments of basic types (bool, string, int, float64), along with associated defaults and descriptions, which then set the standard library flags for parsing command line arguments.

It has functions for populating standard emergent simulation args.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogFilename

func LogFilename(logName, netName, runName string) string

LogFilename returns a standard log file name as netName_runName_logName.tsv

Types

type Args

type Args struct {
	Ints    map[string]*Int
	Bools   map[string]*Bool
	Strings map[string]*String
	Floats  map[string]*Float

	// true when all args have been set to flag package
	Flagged bool `edit:"-"`
}

Args provides maps for storing commandline args.

func (*Args) AddBool

func (ar *Args) AddBool(name string, def bool, desc string)

AddBool adds a new Bool arg

func (*Args) AddFloat

func (ar *Args) AddFloat(name string, def float64, desc string)

AddFloat adds a new Float arg

func (*Args) AddInt

func (ar *Args) AddInt(name string, def int, desc string)

AddInt adds a new Int arg

func (*Args) AddStd

func (ar *Args) AddStd()

AddStd adds the standard command line args used by most sims

func (*Args) AddString

func (ar *Args) AddString(name string, def string, desc string)

AddString adds a new String arg

func (*Args) Bool

func (ar *Args) Bool(name string) bool

Bool returns bool val by name

func (*Args) Flag

func (ar *Args) Flag()

Flag sets all args to the system flag values, only if not already done.

func (*Args) Float

func (ar *Args) Float(name string) float64

Float returns float val by name

func (*Args) Init

func (ar *Args) Init()

Init must be called before use to create all the maps

func (*Args) Int

func (ar *Args) Int(name string) int

Int returns int val by name

func (*Args) Parse

func (ar *Args) Parse()

Parse parses command line args, setting values from command line Any errors will cause the program to exit with error message.

func (*Args) ProcStd

func (ar *Args) ProcStd(params *emer.Params)

ProcStd processes the standard args, after Parse has been called for help, note, params, tag and wts

func (*Args) ProcStdLogs

func (ar *Args) ProcStdLogs(logs *elog.Logs, params *emer.Params, netName string)

ProcStdLogs processes the standard args for log files, setting the log files for standard log file names using netName and params.RunName to identify the network / sim and run params, tag, and starting run number

func (*Args) SetBool

func (ar *Args) SetBool(name string, val bool)

SetBool sets the default and current val

func (*Args) SetFloat

func (ar *Args) SetFloat(name string, val float64)

SetFloat sets the default and current val

func (*Args) SetInt

func (ar *Args) SetInt(name string, val int)

SetInt sets the default and current val

func (*Args) SetString

func (ar *Args) SetString(name string, val string)

SetString sets the default and current val

func (*Args) String

func (ar *Args) String(name string) string

String returns string val by name

func (*Args) Usage

func (ar *Args) Usage()

Usage prints the set of command args. It is called by the help bool arg.

type Bool

type Bool struct {

	// name of arg -- must be unique
	Name string

	// description of arg
	Desc string

	// value as parsed
	Val bool

	// default initial value
	Def bool
}

Bool represents a bool valued arg

func NewBool

func NewBool(name string, def bool, desc string) *Bool

NewBool returns a new Bool arg

func (*Bool) Set

func (vl *Bool) Set(val bool)

Set sets default and current val

type Float

type Float struct {

	// name of arg -- must be unique
	Name string

	// description of arg
	Desc string

	// value as parsed
	Val float64

	// default initial value
	Def float64
}

Float represents a float64 valued arg

func NewFloat

func NewFloat(name string, def float64, desc string) *Float

NewFloat returns a new Float arg

func (*Float) Set

func (vl *Float) Set(val float64)

Set sets default and current val

type Int

type Int struct {

	// name of arg -- must be unique
	Name string

	// description of arg
	Desc string

	// value as parsed
	Val int

	// default initial value
	Def int
}

Int represents a int valued arg

func NewInt

func NewInt(name string, def int, desc string) *Int

NewInt returns a new Int arg

func (*Int) Set

func (vl *Int) Set(val int)

Set sets default and current val

type String

type String struct {

	// name of arg -- must be unique
	Name string

	// description of arg
	Desc string

	// value as parsed
	Val string

	// default initial value
	Def string
}

String represents a string valued arg

func NewString

func NewString(name string, def string, desc string) *String

NewString returns a new String arg

func (*String) Set

func (vl *String) Set(val string)

Set sets default and current val

Jump to

Keyboard shortcuts

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