cmd

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 52 Imported by: 0

Documentation

Overview

TODO: * - csv output * - add command to list original filenames and formatted dates * - add ignore fields * - test on windows

Index

Constants

This section is empty.

Variables

View Source
var DefaultMagic = "PEPE2D constant interval DataSet file"
View Source
var ErrColsNotFound = fmt.Errorf("excel: failed to find col")
View Source
var ErrZeroLenSLice = fmt.Errorf("slice with zero elements")

Functions

func AddSubCommands

func AddSubCommands(cc *CommandsConfig, log zerolog.Logger, s Setup) error

func CreateAndUseFile

func CreateAndUseFile(path string, user UseWriter) (err error)

func Decode

func Decode(coder payload.MultiCoder, b []byte, v interface{}) (err error)

func MakeLuaSandbox

func MakeLuaSandbox(b adaptors.Builder) (*adaptors.LuaSandbox, error)

func MakeSandbox

func MakeSandbox(b adaptors.Builder) (*adaptors.Sandbox, error)

func OpenAndUseFile

func OpenAndUseFile(path string, user UseReader) (err error)

func PadTwo

func PadTwo(ii int) (s string)

func ReadTimeStampTest

func ReadTimeStampTest(l *zerolog.Logger, reader ReadFn) (err error)

func RunLua

func RunLua(args Args) (err error)

func RunLuaLimited

func RunLuaLimited(args Args) (err error)

func ToUpperCamelCase

func ToUpperCamelCase(s string) string

ToUpperCamelCase is an Option.NameFunc that converts strings from snake case to upper camel case.

Types

type AllLoadersFailed

type AllLoadersFailed struct {
	LastErr error
}

func (AllLoadersFailed) Error

func (AllLoadersFailed) Error() (s string)

func (AllLoadersFailed) Unwrap

func (a AllLoadersFailed) Unwrap() (err error)

type Args

type Args struct {
	Source string
	Step   string
	Debug  bool
}

func (Args) GetMode

func (a Args) GetMode(l *log.Logger) (mode Mode, err error)

func (*Args) SetCli

func (a *Args) SetCli(c *cli.Cli)

type BatchRenamer

type BatchRenamer struct {
	Out     Out           `json:"out" toml:"out" mapstructure:"out"`
	Formats Formats       `json:"formats" toml:"formats" mapstructure:"formats"`
	Pattern spath.Pattern `json:"pattern" toml:"pattern" mapstructure:"pattern"`
	// contains filtered or unexported fields
}

func (BatchRenamer) Copy

func (br BatchRenamer) Copy(s *adaptors.Sandbox) (err error)

func (*BatchRenamer) Gather

func (br *BatchRenamer) Gather(s *adaptors.Sandbox) (err error)

func (*BatchRenamer) SubCommands

func (br *BatchRenamer) SubCommands(log zerolog.Logger) (sc SubCommands, err error)

type BatchRunConfig

type BatchRunConfig struct {
	Template string `json:"template" toml:"template" mapstructure:"template"`
	Files    Files
}

type BinaryLoad

type BinaryLoad struct{}
var BinaryLoader BinaryLoad

func (BinaryLoad) LoadRaw

func (BinaryLoad) LoadRaw(r io.ReadSeeker) (data geochem.RawData, err error)

type BundleConfig

type BundleConfig struct {
	Infile  string `json:"infile" toml:"infile" mapstructure:"infile"`
	Outfile string `json:"outfile" toml:"outfile" mapstructure:"outfile"`
}

func (*BundleConfig) Build

func (bc *BundleConfig) Build(s *adaptors.Sandbox) (err error)

func (*BundleConfig) CascadiaBundle

func (bc *BundleConfig) CascadiaBundle(ctx Context, bctx BundleContext) (err error)

func (*BundleConfig) GoqueryBundle

func (bc *BundleConfig) GoqueryBundle(ctx Context, bctx BundleContext) (err error)

func (*BundleConfig) PreProcInclude

func (bc *BundleConfig) PreProcInclude(s *adaptors.Sandbox, bctx BundleContext) (err error)

func (*BundleConfig) SubCommands

func (bc *BundleConfig) SubCommands(log zerolog.Logger) (sc SubCommands, err error)

type BundleContext

type BundleContext struct {
	// contains filtered or unexported fields
}

type CliConfig

type CliConfig struct {
	Executor ExecutorConfig
	Log      LogConfig
	BatchRun BatchRunConfig
}

type Closers

type Closers []io.Closer

func (Closers) CloseAll

func (c Closers) CloseAll() (err error)

type ColNames

type ColNames map[string]string

type Cols

type Cols map[string][]string

func (Cols) MustGet

func (c Cols) MustGet(name string) (rows []string, err error)

type Columns

type Columns struct {
	CellName []string
	FileID   []string
}

type CommandsConfig

type CommandsConfig struct {
	SubCommands SubCommands
	// contains filtered or unexported fields
}

func SetupCommands

func SetupCommands(args Args) (cc CommandsConfig, err error)

func (*CommandsConfig) AddSubSteps

func (cc *CommandsConfig) AddSubSteps(root string, subCmds SubCommands) (err error)

func (CommandsConfig) HandleError

func (cc CommandsConfig) HandleError(err error)

func (CommandsConfig) Run

func (cc CommandsConfig) Run(s *adaptors.Sandbox) (err error)

type Config

type Config struct {
	// contains filtered or unexported fields
}

func (*Config) SetCli

func (c *Config) SetCli(cli *cli.Cli)

func (Config) Setup

func (c Config) Setup() (ctx Context, err error)

type Configured

type Configured struct {
	Engine template.MutEngine
	Paths  template.Paths
}

type Context

type Context struct {
	Streams stream.Streams

	OsFs fs.FS

	Coder payload.MultiCoder
	Log   zerolog.Logger
	// contains filtered or unexported fields
}

func NewContext

func NewContext() (m Context)

func (*Context) AddOpenedStream

func (c *Context) AddOpenedStream(s io.Closer)

func (Context) HandleError

func (ctx Context) HandleError(err error)

type CsvConfig

type CsvConfig struct {
	FilePaths path.PatternMap `json:"filepaths" toml:"filepaths" mapstructure:"filepaths"`
	OutFile   string          `json:"outfile" toml:"outfile" mapstructure:"outfile"`
}

func (*CsvConfig) SubCommands

func (ccfg *CsvConfig) SubCommands(log zerolog.Logger) (sc SubCommands, err error)

type Data

type Data struct {
	Date   time.Time
	Header string
}

type DefaultExcelOpener

type DefaultExcelOpener struct{}

func (DefaultExcelOpener) OpenExcel

func (DefaultExcelOpener) OpenExcel(path string) (f *excelize.File, err error)

type DefaultFormatter

type DefaultFormatter struct {
	// contains filtered or unexported fields
}

func (DefaultFormatter) Date

func (d DefaultFormatter) Date(wr io.Writer, tpl Templates, parts Parts) (err error)

func (DefaultFormatter) Exec

func (d DefaultFormatter) Exec(wr io.Writer, key string, tpl Templates, data interface{}) (err error)

func (DefaultFormatter) InName

func (DefaultFormatter) InName(wr io.Writer, tpl Templates, iiFile int) (err error)

func (DefaultFormatter) OutName

func (d DefaultFormatter) OutName(wr io.Writer, tpl Templates, t time.Time) (err error)

func (DefaultFormatter) OutNameParts

func (d DefaultFormatter) OutNameParts(wr io.Writer, tpl Templates, parts Parts) (err error)

type Dep

type Dep struct {
	Url  string   `json:"url" toml:"url" mapstructure:"url"`
	Path []string `json:"path" toml:"path" mapstructure:"path"`
}

type DepMap

type DepMap map[string]Dep

type DetectedLayout

type DetectedLayout struct {
	// contains filtered or unexported fields
}

func NewDetectedLayout

func NewDetectedLayout(parsers Parsers) (d DetectedLayout)

type Directories

type Directories struct {
	In  string `json:"in" toml:"in"`
	Out string `json:"out" toml:"out"`
}

type Downloader

type Downloader interface {
	Download(url string, w io.Writer) (err error)
}

type Excel

type Excel struct {
	File     string   `json:"file" toml:"file"`
	Sheet    string   `json:"sheet" toml:"sheet"`
	Ignore   Ignore   `json:"ignore" toml:"ignore"`
	ColNames ColNames `json:"column_names" toml:"column_names"`
	// contains filtered or unexported fields
}

func (Excel) GetCols

func (e Excel) GetCols(l zerolog.Logger, ecols *excelize.Cols, names ColNames) (cols Cols, err error)

func (Excel) GetColumns

func (e Excel) GetColumns(l zerolog.Logger, f *excelize.File) (c Cols, err error)

type ExcelOpener

type ExcelOpener interface {
	OpenExcel(path string) (*excelize.File, error)
}

type ExcelReaderPayload

type ExcelReaderPayload struct {
	ExcelOpener
}

func (*ExcelReaderPayload) UnmarshalJSON

func (e *ExcelReaderPayload) UnmarshalJSON(b []byte) (err error)

type ExecutionMode

type ExecutionMode int
const (
	ExecCli ExecutionMode = iota
	ExecLua
)

type ExecutorConfig

type ExecutorConfig struct {
	Formatter *FormatterConfig `json:"formatter" toml:"formatter" mapstructure:"formatter"`
	DryRun    bool             `json:"dry_run" toml:"dry_run" mapstructure:"dry_run"`
}

func (ExecutorConfig) SetupExecutor

func (cfg ExecutorConfig) SetupExecutor(s *adaptors.Sandbox) (command.Executor, error)

type ExecutorMode

type ExecutorMode int

ENUM(

DryRun
Default

)

const (
	// ExecutorModeDryRun is a ExecutorMode of type DryRun.
	ExecutorModeDryRun ExecutorMode = iota
	// ExecutorModeDefault is a ExecutorMode of type Default.
	ExecutorModeDefault
)

func ParseExecutorMode

func ParseExecutorMode(name string) (ExecutorMode, error)

ParseExecutorMode attempts to convert a string to a ExecutorMode.

func (ExecutorMode) MarshalText

func (x ExecutorMode) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (ExecutorMode) String

func (x ExecutorMode) String() string

String implements the Stringer interface.

func (*ExecutorMode) UnmarshalText

func (x *ExecutorMode) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Files

type Files file.GroupSetups

type Format

type Format string
const (
	InFile  Format = "infile"
	OutFile Format = "outfile"
	Date    Format = "date"
)

type Formats

type Formats map[string]string

func (Formats) ToTemplates

func (f Formats) ToTemplates(l zerolog.Logger) (tpls Templates, err error)

type Formatter

type Formatter interface {
	OutName(wr io.Writer, tpl Templates, t time.Time) (err error)
	InName(wr io.Writer, tpl Templates, iiFile int) (err error)
	Date(wr io.Writer, tpl Templates, parts Parts) (err error)
	OutNameParts(wr io.Writer, tpl Templates, parts Parts) (err error)
}

type FormatterConfig

type FormatterConfig struct {
	Template   *string       `json:"template" toml:"template" mapstructure:"template"`
	OutStreams []string      `json:"out_streams" toml:"out_streams" mapstructure:"out_streams"`
	Mode       FormatterMode `json:"mode" toml:"mode" mapstructure:"mode"`
}

func (FormatterConfig) SetupDebug

func (f FormatterConfig) SetupDebug(parser template.Parser, sm stream.Manager) (command.DryRunner, error)

func (FormatterConfig) SetupFormatter

func (f FormatterConfig) SetupFormatter(parser template.Parser) (command.Formatter, error)

type FormatterMode

type FormatterMode int

ENUM(

Line
Default

)

const (
	// FormatterModeLine is a FormatterMode of type Line.
	FormatterModeLine FormatterMode = iota
	// FormatterModeDefault is a FormatterMode of type Default.
	FormatterModeDefault
)

func ParseFormatterMode

func ParseFormatterMode(name string) (FormatterMode, error)

ParseFormatterMode attempts to convert a string to a FormatterMode.

func (FormatterMode) MarshalText

func (x FormatterMode) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (FormatterMode) String

func (x FormatterMode) String() string

String implements the Stringer interface.

func (*FormatterMode) UnmarshalText

func (x *FormatterMode) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type FuzzSelector

type FuzzSelector interface {
	FuzzSelect(in []string) (string, error)
}

type FzFConfig

type FzFConfig struct {
	BinName string   `json:"bin" toml:"bin" mapstructure:"bin"`
	Flags   []string `json:"flags" toml:"flags" mapstructure:"flags"`
}

func (FzFConfig) ToSelector

func (cfg FzFConfig) ToSelector(exec command.Executor) FzfSelector

type FzfSelector

type FzfSelector struct {
	// contains filtered or unexported fields
}

func (FzfSelector) FuzzSelect

func (f FzfSelector) FuzzSelect(in []string) (string, error)

type HardcodedSeparate

type HardcodedSeparate struct {
	// contains filtered or unexported fields
}

func (HardcodedSeparate) SeparateParts

func (h HardcodedSeparate) SeparateParts(dateStr string) (p Parts, err error)

type HeaderMismatch

type HeaderMismatch struct {
	Expected, Got string
}

func (HeaderMismatch) Error

func (h HeaderMismatch) Error() (s string)

type Ignore

type Ignore struct {
	LineStart string   `json:"line_start" toml:"line_start"`
	FileIDs   []string `json:"file_ids" toml:"file_ids"`
}

type Imports

type Imports map[string]string

type InOutIndices

type InOutIndices map[int]int

type KeyContext

type KeyContext struct {
	Realm    string
	Password string
	Config   PasswordConfig
	KeyType  gokey.KeyType
}

func (KeyContext) Get

func (kc KeyContext) Get() (pass string, err error)

type LineFormatter

type LineFormatter struct {
	// contains filtered or unexported fields
}

func (LineFormatter) FormatCommand

func (lf LineFormatter) FormatCommand(w io.Writer, s command.Setup, opt command.Options) error

type LoadRawFn

type LoadRawFn func(r io.Reader) (data RawData, err error)

type LogConfig

type LogConfig struct {
	File  *string `json:"file" toml:"file"`
	Level string  `json:"level" toml:"level"`
}

func (LogConfig) Setup

func (lc LogConfig) Setup() (log zerolog.Logger, err error)

type Logger

type Logger zerolog.Logger

type MapOther

type MapOther map[string]any

type Mode

type Mode int

ENUM(

Config
Lua

)

const (
	// ModeConfig is a Mode of type Config.
	ModeConfig Mode = iota
	// ModeLua is a Mode of type Lua.
	ModeLua
)

func ParseMode

func ParseMode(name string) (Mode, error)

ParseMode attempts to convert a string to a Mode.

func (Mode) MarshalText

func (x Mode) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Mode) String

func (x Mode) String() string

String implements the Stringer interface.

func (*Mode) UnmarshalText

func (x *Mode) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type MultiLoader

type MultiLoader struct {
	// contains filtered or unexported fields
}

func (MultiLoader) LoadRaw

func (m MultiLoader) LoadRaw(r io.ReadSeeker) (data RawData, err error)

type OsCopier

type OsCopier struct {
	// contains filtered or unexported fields
}

func (OsCopier) Copy

func (o OsCopier) Copy(in, out string) (err error)

type Out

type Out struct {
	File      string `json:"file" toml:"file"`
	Directory string `json:"directory" toml:"directory"`
}

type Params

type Params map[string]interface{}

type Parsers

type Parsers struct {
	TimeZone parser.TimeZone
	Time     parser.Time
}

type Part

type Part int

ENUM(

StringDay
StringMonth
Day
Time
Year
TimeZone
Max

)

const (
	// PartStringDay is a Part of type StringDay.
	PartStringDay Part = iota
	// PartStringMonth is a Part of type StringMonth.
	PartStringMonth
	// PartDay is a Part of type Day.
	PartDay
	// PartTime is a Part of type Time.
	PartTime
	// PartYear is a Part of type Year.
	PartYear
	// PartTimeZone is a Part of type TimeZone.
	PartTimeZone
	// PartMax is a Part of type Max.
	PartMax
)

func ParsePart

func ParsePart(name string) (Part, error)

ParsePart attempts to convert a string to a Part.

func (Part) MarshalText

func (x Part) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Part) String

func (x Part) String() string

String implements the Stringer interface.

func (*Part) UnmarshalText

func (x *Part) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Parts

type Parts struct {
	// contains filtered or unexported fields
}

func (Parts) Get

func (p Parts) Get(pi Part) (s string)

func (*Parts) Set

func (p *Parts) Set(pi Part, s string)

func (Parts) ToParams

func (p Parts) ToParams() (params map[string]string, err error)

type PartsSeparator

type PartsSeparator interface {
	SeparateParts(dateStr string) (p Parts, err error)
}

type PasswordConfig

type PasswordConfig struct {
	Spec    gokey.PasswordSpec `json:"spec" toml:"spec" mapstructure:"spec"`
	KeyType string             `json:"key_type" toml:"key_type" mapstructure:"key_type"`
	Realms  []Realm            `json:"realms" toml:"realms" mapstructure:"realms"`
}

func (*PasswordConfig) SubCommands

func (pc *PasswordConfig) SubCommands() (sc SubCommands)

func (*PasswordConfig) ToKeyContext

func (pc *PasswordConfig) ToKeyContext(s *adaptors.Sandbox) (kc KeyContext, err error)

type Paths

type Paths struct {
	Data    data.NamedFieldsRef
	Fields  data.InOutFields
	Indices InOutIndices
	IRows   []int
	Encoded bool
}

func (Paths) GetData

func (p Paths) GetData() (d data.StringData)

func (Paths) NamedFields

func (p Paths) NamedFields() (nf *data.NamedFields)

type RawData

type RawData struct {
	Header [37]byte
	Pad    [88]byte
	Date   [59]byte
}

type RawLoadFn

type RawLoadFn func(r io.Reader) (data RawData, err error)

type RawLoader

type RawLoader interface {
	LoadRaw(r io.ReadSeeker) (data RawData, err error)
}

type RawParser

type RawParser interface {
	ParseRawData(raw RawData) (d Data, err error)
}

type ReadFn

type ReadFn func(r io.Reader) (err error)

type Realm

type Realm struct {
	Name string `json:"name" toml:"name" mapstructure:"name"`
	Seed string `json:"seed" toml:"seed" mapstructure:"seed"`
}

type Renames

type Renames struct {
	InFiles  []string `json:"infiles"`
	Dates    []string `json:"dates"`
	OutFiles []string `json:"outfiles"`
}

func (*Renames) Deserialize

func (rn *Renames) Deserialize(man data.NamedMethods, r *csv.Reader) (err error)

func (Renames) Serialize

func (r Renames) Serialize(man data.NamedMethods, w *csv.Writer) (err error)

type ScoreCalculator

type ScoreCalculator struct {
	// contains filtered or unexported fields
}

func (*ScoreCalculator) SetCli

func (s *ScoreCalculator) SetCli(c *cli.Cli)

type ScoreCalculatorSetup

type ScoreCalculatorSetup struct {
	// contains filtered or unexported fields
}

func (*ScoreCalculatorSetup) Set

func (s *ScoreCalculatorSetup) Set(str string) (err error)

func (ScoreCalculatorSetup) String

func (s ScoreCalculatorSetup) String() (str string)

type SeparateFn

type SeparateFn func(dateStr string) (p Parts, err error)

type Setup

type Setup struct {
	TemplateConfig  TemplateConfig  `json:"templates" toml:"templates" mapstructure:"templates"`
	ThirdPartySetup ThirdPartySetup `json:"third_party" toml:"third_party" mapstructure:"third_party"`
	Bundle          BundleConfig    `json:"bundle" toml:"bundle" mapstructure:"bundle"`
	Logging         LogConfig       `json:"logging" toml:"logging" mapstructure:"logging"`
	Csv             CsvConfig       `json:"csv" toml:"csv" mapstructure:"csv"`
	BatchRenamer    BatchRenamer    `json:"batch_rename" toml:"batch_rename" mapstructure:"batch_rename"`
}

func DecodeSetup

func DecodeSetup(coder payload.MultiCoder, file string) (s Setup, err error)

func (Setup) DoSetup

func (s Setup) DoSetup() (cc CommandsConfig, err error)

type SubCommand

type SubCommand func(s *adaptors.Sandbox) (err error)

type SubCommandInit

type SubCommandInit interface {
	SubCommands(zerolog.Logger) (sc SubCommands, err error)
}

type SubCommandInits

type SubCommandInits map[string]SubCommandInit

type SubCommands

type SubCommands map[string]SubCommand

type TemplateConfig

type TemplateConfig struct {
	OutDir   *string         `json:"outdir" toml:"outdir" mapstructure:"outdir"`
	OutFiles template.Paths  `json:"outfiles" toml:"outfiles" mapstructure:"outfiles"`
	Env      template.Values `json:"config" toml:"config" mapstructure:"env"`
	Imports  Imports         `json:"imports" toml:"imports" mapstructure:"imports"`
	Sources  path.PatternMap `json:"sources" toml:"sources" mapstructure:"sources"`
}

func (*TemplateConfig) Render

func (t *TemplateConfig) Render(s *adaptors.Sandbox) (err error)

func (*TemplateConfig) SubCommands

func (t *TemplateConfig) SubCommands(log zerolog.Logger) (sc SubCommands, err error)

type Templates

type Templates struct {
	// contains filtered or unexported fields
}

type Tester

type Tester struct {
	// contains filtered or unexported fields
}

func (Tester) RunMain

func (t Tester) RunMain(m Context) (err error)

func (*Tester) SetCli

func (t *Tester) SetCli(c *cli.Cli)

type ThirdPartySetup

type ThirdPartySetup struct {
	Deps DepMap    `json:"resources" toml:"resources" mapstructure:"deps"`
	Root *[]string `json:"root_dir" toml:"root_dir" mapstructure:"root"`
}

func (ThirdPartySetup) DownloadFiles

func (s ThirdPartySetup) DownloadFiles(sb *adaptors.Sandbox) (err error)

type TimeStampFromOffset

type TimeStampFromOffset struct {
	// contains filtered or unexported fields
}

type TimeStampIO

type TimeStampIO struct {
	Loader    geochem.RawLoader
	Separator PartsSeparator
	Log       zerolog.Logger
}

func (TimeStampIO) LoadParts

func (t TimeStampIO) LoadParts(r io.ReadSeeker) (p Parts, err error)

func (TimeStampIO) PartsFromFile

func (t TimeStampIO) PartsFromFile(path string) (p Parts, err error)

type TimeStampParser

type TimeStampParser struct {
	// contains filtered or unexported fields
}

func NewTimeStampParser

func NewTimeStampParser(magic string, layout DetectedLayout, l *zerolog.Logger) (t TimeStampParser)

type TimeStampReader

type TimeStampReader interface {
	ReadTimeStamp(r io.Reader) (t time.Time, err error)
}

type UseReader

type UseReader func(r io.Reader) (err error)

type UseWriter

type UseWriter func(w io.Writer) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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