cli

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: GPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli defines the command-line interface for invoicer.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the app version reported by --version. The build stamps it with -ldflags. A binary without a stamp reports "dev".

Functions

func RunSetConfig

func RunSetConfig(s *SetConfigCmd, path string) error

RunSetConfig writes the given SetConfigCmd options to the config file at path. If path is empty, the default path (~/.invoicer/config.yaml) is used. This function is exported for testability.

Types

type CLI

type CLI struct {
	// Version prints the app version and exits.
	Version kong.VersionFlag `help:"Print the app version and exit."`

	// Generate is the default subcommand for generating an invoice.
	Generate GenerateCmd `cmd:"" default:"withargs" help:"Generate an invoice for a given month."`

	// Set is the 'set' subcommand group for managing configuration.
	Set SetCmd `cmd:"" name:"set" help:"Subcommands for managing invoicer configuration."`

	// Remove is the subcommand for deleting a stored invoice.
	Remove RemoveCmd `cmd:"" help:"Remove a stored invoice by its identifier."`

	// Web is the subcommand for serving the invoice web app.
	Web WebCmd `cmd:"" help:"Start the invoice web server."`
}

CLI is the root command for invoicer.

type GenerateCmd

type GenerateCmd struct {
	// Month is the month to invoice for (text or numeric). Defaults to previous month.
	Month string `arg:"" optional:"" help:"Month to invoice for (e.g. 'january', 'jan', or '1'). Defaults to previous month."`

	// Year is the year of the month to invoice for. Defaults to the current year,
	// except the previous-month default at a year boundary.
	Year int `` /* 143-byte string literal not displayed */

	// Vendor is the name of the contractor sending the invoice.
	Vendor string `short:"v" help:"Name of the contractor sending the invoice. Required without config."`

	// Customer is the name of the customer receiving the invoice.
	Customer string `short:"c" help:"Name of the customer receiving the invoice. Required without config."`

	// Project is an optional project name to annotate the invoice with.
	Project string `help:"Name of the project to annotate the invoice with."`

	// Database is the path to the invoice database.
	Database string `help:"Path to the invoice database. Defaults to ~/.invoicer/invoices.db."`

	// Rate is the hourly rate for the contractor.
	Rate float64 `short:"r" help:"Hourly rate in dollars. Required without config."`

	// Hours is the number of hours per week worked.
	Hours float64 `short:"H" help:"Hours per week worked. Required without config."`
}

GenerateCmd is the default subcommand for generating an invoice.

func (*GenerateCmd) Run

func (c *GenerateCmd) Run() error

Run executes the generate subcommand (invoice generation).

type RemoveCmd added in v0.2.1

type RemoveCmd struct {
	// ID is the identifier of the invoice to remove.
	ID string `arg:"" help:"Identifier of the invoice to remove."`

	// Database is the path to the invoice database.
	Database string `help:"Path to the invoice database. Defaults to ~/.invoicer/invoices.db."`
}

RemoveCmd deletes a stored invoice.

func (*RemoveCmd) Run added in v0.2.1

func (c *RemoveCmd) Run() error

Run executes the remove subcommand.

type ResolvedOptions

type ResolvedOptions struct {
	Month    string
	Year     int
	Vendor   string
	Customer string
	Project  string
	Rate     float64
	Hours    float64
	Database string
}

ResolvedOptions holds the final merged values after CLI and config are combined.

type SetCmd

type SetCmd struct {
	Config SetConfigCmd `cmd:"" name:"config" help:"Write configuration options to ~/.invoicer/config.yaml."`
}

SetCmd groups subcommands under "set".

type SetConfigCmd

type SetConfigCmd struct {
	// Vendor is the name of the contractor sending the invoice.
	Vendor string `help:"Name of the contractor sending the invoice."`

	// Customer is the name of the customer receiving the invoice.
	Customer string `help:"Name of the customer receiving the invoice."`

	// Project is an optional project name to annotate invoices with.
	Project string `help:"Name of the project to annotate invoices with."`

	// Database is the path to the invoice database.
	Database string `help:"Path to the invoice database."`

	// Rate is the hourly rate for the contractor.
	Rate float64 `help:"Hourly rate in dollars."`

	// Hours is the number of hours per week worked.
	Hours float64 `help:"Hours per week worked."`
}

SetConfigCmd is the 'set config' subcommand. It accepts the same options as the main command and writes them to ~/.invoicer/config.yaml. Only explicitly provided options are written; others are left unchanged.

func (*SetConfigCmd) Run

func (s *SetConfigCmd) Run() error

Run executes the 'set config' subcommand, writing specified options to ~/.invoicer/config.yaml. Only options that are explicitly provided are updated; others remain unchanged.

type WebCmd

type WebCmd struct {
	// Address is the address the web server listens on.
	Address string `help:"Address the web server listens on." default:":8080"`

	// Database is the path to the invoice database.
	Database string `help:"Path to the invoice database. Defaults to ~/.invoicer/invoices.db."`
}

WebCmd starts the invoice web server.

func (*WebCmd) Run

func (c *WebCmd) Run() error

Run executes the web subcommand.

type WebOptions

type WebOptions struct {
	Address  string
	Database string

	// Access is nil when the config omits every access setting, which runs the
	// web app without sign-in for local development.
	Access *access.Options
}

WebOptions holds the web server settings after CLI and config are combined.

Jump to

Keyboard shortcuts

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