Skip to content

Commit

Permalink
New API update in readme. Using '~/.local/share'. Added clean group f…
Browse files Browse the repository at this point in the history
…unction for new group rules.
  • Loading branch information
alanxoc3 committed Apr 21, 2021
1 parent e80c4d3 commit 6122a8a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,47 @@ hook global RawKey . %{
```

## Notes
Groups naming rules:
- `.tt` will be removed if at end of group/subgroup.
- Name cannot start with a `.`.
- Slashes denote sub groups.
- Timeout, begin ts, & end ts all go in cache.

Api idea:
```
ttrack
ttrack --help
ttrack help
ttrack version
ttrack groups
<group-1>
<group-2>
ttrack rec <group>... 10m30s
# Only sets the cache if possible. May update files too.
ttrack set <group>... 2021-01-03:+20m30s
ttrack set <group>... 2021-01-03:-30m
ttrack set <group>... :-30m
ttrack rec <group> 10m30s
ttrack set <group> 2021-01-03 10m30s
ttrack timer <group> 10m30s
ttrack del <group>
ttrack cp <group> <group> --begin-date=2021-01-01 --end-date=2021-01-03
ttrack del <group>... --recursive
# Removes both from cache and filesystem.
ttrack mv <group>... <group> --begin-date=2021-01-01 --end-date=2021-01-03 --recursive
ttrack cp <group>... <group> --begin-date=2021-01-01 --end-date=2021-01-03 --recursive
ttrack tidy
# Cleans the cache file.
# Formats all '.tt' files.
ttrack show [<group>]... --recursive
<group-1>
<group-1>/<sub-group
ttrack list <group> --begin-date=2021-01-01 --end-date=2021-01-04
2021-01-01: 10m
2021-01-02: 13s
2021-01-03: 30m
2021-01-04: 1h
ttrack list <group>... --begin-date=2021-01-01 --end-date=2021-01-04 --recursive
2021-01-01:10m
2021-01-02:13s
2021-01-03:30m
2021-01-04:1h
ttrack agg <group> --begin-date=2021-01-01 --end-date=2021-01-04
ttrack agg <group>... --begin-date=2021-01-01 --end-date=2021-01-04 --recursive
1h40m13s
```

Expand Down
20 changes: 19 additions & 1 deletion main-util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"os/user"
"time"
"strings"

bolt "go.etcd.io/bbolt"
)
Expand All @@ -27,7 +28,7 @@ func (d *date) String() string {

func getHomeFilePath(filename string) (string, error) {
if usr, err := user.Current(); err == nil {
return usr.HomeDir + "/.config/ttrack/" + filename, nil
return usr.HomeDir + "/.local/share/ttrack/" + filename, nil
} else {
return "", err
}
Expand Down Expand Up @@ -64,3 +65,20 @@ func updateCmd(f func(*bolt.Tx) error) {
panic(err)
}
}

func clean_group(group string) string {
fields := strings.FieldsFunc(group, func(c rune) bool { return c == '/' })

newFields := []string{}
for _, v := range fields {
for i, r := range v {
if r != '.' {
newFields = append(newFields, v[i:])
break
}
}
}

group = strings.Join(newFields, "/")
return group
}

0 comments on commit 6122a8a

Please sign in to comment.