Dev a few more operations
* Archive * Config * Pull out filter generation (from list) for reuse
This commit is contained in:
@@ -7,20 +7,16 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.bullercodeworks.com/brian/gime/cli"
|
||||
"git.bullercodeworks.com/brian/gime/util"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// archiveCmd represents the archive command
|
||||
var archiveCmd = &cobra.Command{
|
||||
Use: "archive",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
RunE: opArchive,
|
||||
Short: "Archive timers to the done file",
|
||||
RunE: opArchive,
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -28,6 +24,26 @@ func init() {
|
||||
}
|
||||
|
||||
func opArchive(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("archive called")
|
||||
var err error
|
||||
p := cli.Program{}
|
||||
err = p.Initialize()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = p.LoadTimerList(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
filter := util.BuildFilterFromArgs(args)
|
||||
list := p.TimerList.Filter(filter)
|
||||
for _, v := range list.GetTimerSlice() {
|
||||
if v.Finished {
|
||||
if err := p.ArchiveTimer(v); err != nil {
|
||||
return fmt.Errorf("Error archiving task %d: %w", v.Id, err)
|
||||
}
|
||||
fmt.Println(p.GetDoneTimerString(v))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user