dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
679 stars 75 forks source link

Config YAML: support per-project configurations #107

Closed jrcasso closed 3 years ago

jrcasso commented 3 years ago

For contractors with a large number of projects, it would be nice to be able to configure per-project options.

dominikbraun commented 3 years ago

Thanks for this feature request! Absolutely makes sense.


To solve this and #108, it would probably be sufficient to create a new config.Project type that stores per-project configuration. Those project configurations could then be stored as a map in config.Config with the map key corresponding to the project key:

type Config struct {
    Store      string             `json:"store"`
    Use12Hours bool               `json:"use12hours"`
    Editor     string             `json:"editor"`
    Projects   map[string]Project `json:"projects"`
}

type Project struct {
    Billable bool `json:"billable"`
}

This would allow the YAML configuration to look as follows:

editor: code
projects:
  make-coffee:
    billable: false
  my-project:
    billable: true

Does this YAML look approachable, @jrcasso?

If I'm not missing something, this should be pretty straight-forward to implement.

jrcasso commented 3 years ago

@dominikbraun Yep, approach LGTM!