settings

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(projectName string, hourlyRate float64) error

func CreateWithTemplate

func CreateWithTemplate(projectName string, hourlyRate float64, description string, exportPath string) error

func FormatDate

func FormatDate(t time.Time) string

func FormatDateDashed

func FormatDateDashed(t time.Time) string

func FormatDateLong

func FormatDateLong(t time.Time) string

func FormatDateTime

func FormatDateTime(t time.Time) string

func FormatDateTimeDashed

func FormatDateTimeDashed(t time.Time) string

func FormatDateTimeLong

func FormatDateTimeLong(t time.Time) string

func FormatTime

func FormatTime(t time.Time) string

func FormatTimePadded

func FormatTimePadded(t time.Time) string

func GetDisplayTimezone added in v0.4.5

func GetDisplayTimezone() *time.Location

GetDisplayTimezone returns the user's configured timezone or local timezone as fallback

func GetGlobalConfigPath

func GetGlobalConfigPath() (string, error)

func GetProjectsPath added in v0.5.0

func GetProjectsPath() (string, error)

GetProjectsPath returns the path to the global projects registry file

Types

type Config

type Config struct {
	ProjectName string  `yaml:"project_name"`
	HourlyRate  float64 `yaml:"hourly_rate,omitempty"`
	Description string  `yaml:"description,omitempty"`
	ExportPath  string  `yaml:"export_path,omitempty"`
}

IMPORTANT: When adding new fields to this struct, also update configTemplate below.

func FindAndLoad

func FindAndLoad() (*Config, string, error)

func Load

func Load(path string) (*Config, error)

func (*Config) Save

func (c *Config) Save(path string) error

type GlobalConfig

type GlobalConfig struct {
	Currency   string `yaml:"currency"`
	DateFormat string `yaml:"date_format,omitempty"`
	TimeFormat string `yaml:"time_format,omitempty"`
	Timezone   string `yaml:"timezone,omitempty"`
	ExportPath string `yaml:"export_path,omitempty"`
}

func DefaultGlobalConfig

func DefaultGlobalConfig() *GlobalConfig

func LoadGlobalConfig

func LoadGlobalConfig() (*GlobalConfig, error)

func (*GlobalConfig) Save

func (gc *GlobalConfig) Save() error

type GlobalProject added in v0.5.0

type GlobalProject struct {
	Name        string   `yaml:"name"`
	HourlyRate  *float64 `yaml:"hourly_rate,omitempty"`
	Description string   `yaml:"description,omitempty"`
	ExportPath  string   `yaml:"export_path,omitempty"`
}

GlobalProject represents a global project configuration

type ProjectsRegistry added in v0.5.0

type ProjectsRegistry struct {
	Projects []GlobalProject `yaml:"projects"`
}

ProjectsRegistry holds all global projects

func LoadProjects added in v0.5.0

func LoadProjects() (*ProjectsRegistry, error)

LoadProjects loads the global projects registry

func (*ProjectsRegistry) AddProject added in v0.5.0

func (pr *ProjectsRegistry) AddProject(project GlobalProject) error

AddProject adds a new project to the registry

func (*ProjectsRegistry) DeleteProject added in v0.5.0

func (pr *ProjectsRegistry) DeleteProject(name string) error

DeleteProject removes a project from the registry

func (*ProjectsRegistry) Exists added in v0.5.0

func (pr *ProjectsRegistry) Exists(name string) bool

Exists checks if a project exists in the registry (case-insensitive)

func (*ProjectsRegistry) GetProject added in v0.5.0

func (pr *ProjectsRegistry) GetProject(name string) (*GlobalProject, error)

GetProject retrieves a project by name

func (*ProjectsRegistry) ListProjects added in v0.5.0

func (pr *ProjectsRegistry) ListProjects() []GlobalProject

ListProjects returns all projects in the registry

func (*ProjectsRegistry) Save added in v0.5.0

func (pr *ProjectsRegistry) Save() error

Save saves the projects registry to disk

func (*ProjectsRegistry) UpdateProject added in v0.5.0

func (pr *ProjectsRegistry) UpdateProject(name string, updatedProject GlobalProject) error

UpdateProject updates an existing project in the registry

Jump to

Keyboard shortcuts

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