@@ -12,13 +12,15 @@ import (
1212
1313// Client wraps the Taskwarrior CLI
1414type Client struct {
15- dataLocation string
15+ dataLocation string
16+ taskrcLocation string
1617}
1718
1819// NewClient creates a new Taskwarrior client
19- func NewClient (dataLocation string ) * Client {
20+ func NewClient (dataLocation , taskrcLocation string ) * Client {
2021 return & Client {
21- dataLocation : dataLocation ,
22+ dataLocation : dataLocation ,
23+ taskrcLocation : taskrcLocation ,
2224 }
2325}
2426
@@ -366,8 +368,20 @@ func (c *Client) buildCommand(args ...string) *exec.Cmd {
366368 }
367369 }
368370
369- // Prepend data location override
370- allArgs := append ([]string {fmt .Sprintf ("rc.data.location=%s" , dataLocation )}, args ... )
371+ taskrcLocation := c .taskrcLocation
372+ if strings .HasPrefix (taskrcLocation , "~/" ) {
373+ home , err := os .UserHomeDir ()
374+ if err == nil {
375+ taskrcLocation = strings .Replace (taskrcLocation , "~" , home , 1 )
376+ }
377+ }
378+
379+ // Prepend data location and taskrc location overrides
380+ allArgs := []string {fmt .Sprintf ("rc.data.location=%s" , dataLocation )}
381+ if taskrcLocation != "" {
382+ allArgs = append (allArgs , fmt .Sprintf ("rc:%s" , taskrcLocation ))
383+ }
384+ allArgs = append (allArgs , args ... )
371385 log .Printf ("Running command: task %s" , strings .Join (allArgs , " " ))
372386 cmd := exec .Command ("task" , allArgs ... )
373387 return cmd
0 commit comments