cmd

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(args []string, config Config) error

func Today added in v0.4.0

func Today(timestamp time.Time) (time.Time, error)

TODO: May be shared by other code

Types

type Config

type Config struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

TODO: Make GetAllEntries and OpenWriter/Reader testable

type LogCmd added in v0.3.0

type LogCmd struct {
	Category string    `arg:"" required:"" help:"Category to log the new entry under. (Use '-' to use the last category logged)"`
	Note     []string  `arg:"" optional:"" help:"Description for the entry"`
	Date     time.Time `short:"d" optional:"" format:"2006-01-02" help:"Date to log (default: today)"`
	Time     time.Time `short:"t" optional:"" format:"15:04" help:"Time to log entry at (default: now)"`
}

func (*LogCmd) AfterApply added in v0.6.0

func (cmd *LogCmd) AfterApply() error

func (*LogCmd) Run added in v0.4.0

func (cmd *LogCmd) Run(log string) error

type ReportCmd added in v0.3.0

type ReportCmd struct {
	// TODO: Times are tricky... Make sure this is the same timezone as time.Now()
	Start           time.Time `short:"s" optional:"" format:"2006-01-02" help:"Date to start report from (default: today)"`
	End             time.Time `short:"e" optional:"" format:"2006-01-02" help:"Date to end report from (default: time.Now)"`
	UseRootCategory bool      `` /* 145-byte string literal not displayed */
	DurationFormat  string    `` /* 129-byte string literal not displayed */
	// TODO: Make this a cleaner API?
	Output   report.OutputFormat `short:"o" enum:"default,markdown,html,json" default:"default" help:"Premade formats (default,markdown,html,json)"`
	Template string              `type:"existingfile" help:"File text/template to use in making report (Overrides --output)"`
	// TODO: This gets tricky since it could also be time...
	// TODO: Also probably should be an ENV?
	Until time.Duration `short:"u" help:"Desired duration of work to log"`
	// contains filtered or unexported fields
}

func (*ReportCmd) AfterApply added in v0.6.0

func (cmd *ReportCmd) AfterApply() error

func (*ReportCmd) Run added in v0.3.0

func (cmd *ReportCmd) Run(stdout io.Writer, log string) error

type RootCmd added in v0.3.1

type RootCmd struct {
	Report  ReportCmd `cmd:"" help:"Print summary report"`
	Serve   ServeCmd  `cmd:"" help:"Run gotime as a HTTP server via localhost."`
	Log     LogCmd    `default:"withargs" cmd:"" help:"Log using a custom category and note."`
	LogFile string    `default:"~/.config/gotime.csv" help:"Path to log file." env:"GOTIME_LOG"`
}

type ServeCmd added in v0.8.0

type ServeCmd struct {
	Port   string    `short:"p" default:"8080" help:"Port to run server on"`
	Report ReportCmd `embed:""`
}

func (*ServeCmd) AfterApply added in v0.8.0

func (cmd *ServeCmd) AfterApply() error

func (*ServeCmd) Run added in v0.8.0

func (cmd *ServeCmd) Run(stdout io.Writer, log string) error

Jump to

Keyboard shortcuts

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