Documentation ¶
Overview ¶
Package cmd defines commands which generally read, transform, and write ADIF logfiles. Commands are invoked by a main program like adifmt, which configures a Context value. Most commands read ADIF files by name and print an ADIF logfile to standard output, but some have different input and output behavior.
Index ¶
- Constants
- Variables
- func ValidateAlphanumName(name, value string) error
- type Command
- type Condition
- type ConditionValue
- type Context
- type EditContext
- type EvaluationContext
- type FieldAssignments
- type FieldDelimiters
- type FieldList
- type FindContext
- type FlattenContext
- type InferContext
- type NamedReader
- type SaveContext
- type SelectContext
- type SortContext
- type TimeZone
- type UserdefFieldList
- type ValidateContext
Constants ¶
View Source
const ( OpEqual operator = "=" OpLessThan = "<" OpLessThanEqual = "<=" OpGreaterThan = ">" OpGreaterThanEqual = ">=" )
Variables ¶
View Source
var Cat = Command{Name: "cat", Run: runCat,
Description: "Concatenate all input files to standard output"}
View Source
var Edit = Command{Name: "edit", Run: runEdit, Help: helpEdit,
Description: "Add, change, remove, or adjust field values"}
View Source
var Find = Command{Name: "find", Run: runFind, Help: helpFind,
Description: "Include only records matching a condition"}
View Source
var Fix = Command{Name: "fix", Run: runFix, Help: helpFix,
Description: "Correct field formats to match the ADIF specification"}
View Source
var Flatten = Command{Name: "flatten", Run: runFlatten, Help: helpFlatten,
Description: "Flatten multi-instance fields to multiple records"}
View Source
var Infer = Command{Name: "infer", Run: runInfer, Help: helpInfer,
Description: "Add missing fields based on present fields"}
View Source
var Save = Command{Name: "save", Run: runSave, Help: helpSave,
Description: "Save standard input to file(s) with format inferred by extension"}
View Source
var Select = Command{Name: "select", Run: runSelect, Help: helpSelect,
Description: "Print only specific fields from the input"}
View Source
var Sort = Command{Name: "sort", Run: runSort, Help: helpSort,
Description: "Sort records by a list of fields"}
View Source
var Validate = Command{Name: "validate", Run: runValidate, Help: helpValidate,
Description: "Validate field values; non-zero exit and no stdout if invalid"}
Functions ¶
func ValidateAlphanumName ¶
Types ¶
type Condition ¶ added in v0.1.7
type Condition interface { Evaluate(EvaluationContext) bool // maybe (bool, error)? String() string }
type ConditionValue ¶ added in v0.1.7
type ConditionValue struct {
// contains filtered or unexported fields
}
func (*ConditionValue) Get ¶ added in v0.1.7
func (cv *ConditionValue) Get() junction
func (*ConditionValue) IfFlag ¶ added in v0.1.7
func (cv *ConditionValue) IfFlag() flag.Value
func (*ConditionValue) IfNotFlag ¶ added in v0.1.7
func (cv *ConditionValue) IfNotFlag() flag.Value
func (*ConditionValue) OrIfFlag ¶ added in v0.1.7
func (cv *ConditionValue) OrIfFlag() flag.Value
func (*ConditionValue) OrIfNotFlag ¶ added in v0.1.7
func (cv *ConditionValue) OrIfNotFlag() flag.Value
type Context ¶
type Context struct { InputFormat adif.Format OutputFormat adif.Format Readers map[adif.Format]adif.Reader Writers map[adif.Format]adif.Writer Out io.Writer Locale language.Tag CommandCtx any FieldOrder FieldList UserdefFields UserdefFieldList SuppressAppHeaders bool Prepare func(*adif.Logfile) // contains filtered or unexported fields }
type EditContext ¶
type EditContext struct { Add FieldAssignments Set FieldAssignments Rename FieldAssignments Remove FieldList RemoveBlank bool Cond ConditionValue FromZone TimeZone ToZone TimeZone }
type EvaluationContext ¶ added in v0.1.7
type FieldAssignments ¶
type FieldAssignments struct {
// contains filtered or unexported fields
}
func NewFieldAssignments ¶
func NewFieldAssignments(validate func(k, v string) error) FieldAssignments
func (*FieldAssignments) Get ¶
func (a *FieldAssignments) Get() FieldAssignments
func (*FieldAssignments) Set ¶
func (f *FieldAssignments) Set(s string) error
func (*FieldAssignments) String ¶
func (a *FieldAssignments) String() string
type FieldDelimiters ¶ added in v0.1.15
func (FieldDelimiters) Get ¶ added in v0.1.15
func (f FieldDelimiters) Get() FieldDelimiters
func (FieldDelimiters) Set ¶ added in v0.1.15
func (f FieldDelimiters) Set(s string) error
func (FieldDelimiters) String ¶ added in v0.1.15
func (f FieldDelimiters) String() string
type FindContext ¶ added in v0.1.7
type FindContext struct {
Cond ConditionValue
}
type FlattenContext ¶ added in v0.1.13
type FlattenContext struct { Fields FieldList Delimiters FieldDelimiters }
type InferContext ¶
type NamedReader ¶
type NamedReader interface { io.ReadCloser Name() string }
NamedReader is an io.Reader with a name. os.File implements this interface and stringReader is provided for testing.
type SaveContext ¶
type SelectContext ¶
type SelectContext struct {
Fields FieldList
}
type SortContext ¶ added in v0.1.7
type SortContext struct {
Fields FieldList
}
type UserdefFieldList ¶
type UserdefFieldList []adif.UserdefField
func (*UserdefFieldList) Get ¶
func (f *UserdefFieldList) Get() UserdefFieldList
func (*UserdefFieldList) Set ¶
func (f *UserdefFieldList) Set(s string) error
func (*UserdefFieldList) String ¶
func (f *UserdefFieldList) String() string
type ValidateContext ¶ added in v0.1.11
type ValidateContext struct {
RequiredFields FieldList
}
Click to show internal directories.
Click to hide internal directories.