This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
redtime/cmd_activities.go
Dani Rodríguez 8675a755f2 activities: include all enum fields
This is a breaking change that modifies the return type of
fetchActivities() so that instead of returning a map[int]string that
maps an ID with the name of the activity with such ID, it returns a
map[uint]remoteActivityType.

remoteActivityType is a remote activity and it holds more than just the
activity name, it also includes two extra fields exposed by the API:

* IsDefault (is_default): the enumerator value can be used as default
  when not given (i.e., default issue type, default activity type...)
* Active (active): the enumerator value can be used for new entries.

The ID type has changed from int to uint following the efforts of
coalescing all remote identifiers to uint.

The activities subcommand now outputs all the fields of the enumerator.
2023-08-30 11:46:41 +02:00

24 lines
423 B
Go

package main
import "github.com/rodaine/table"
func doListActivities() {
acts, err := context.fetchActivities()
if err != nil {
panic(err)
}
tbl := table.New("ID", "ACTIVITY", "DEF", "ACT")
for id, act := range acts {
isDefault := " "
isActive := " "
if act.IsDefault {
isDefault = "[X]"
}
if act.Active {
isActive = "[X]"
}
tbl.AddRow(id, act.Name, isDefault, isActive)
}
tbl.Print()
}