-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tasks): add multiple sort options
* fix: fix issue with different ordering * feat: add sort by due date and title * release: add goreleaser * feat: move version string to build ldflag
- Loading branch information
Showing
7 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ google-tasks-cli | |
gtasks | ||
gtasks.exe | ||
bin/* | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
project_name: gtasks | ||
|
||
release: | ||
prerelease: auto | ||
draft: true | ||
name_template: "gtasks {{.Version}}" | ||
|
||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
# you may remove this if you don't need go generate | ||
# - go generate ./... | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
ldflags: | ||
- -X github.com/BRO3886/gtasks/cmd.Version={{.Version}} | ||
archives: | ||
- replacements: | ||
darwin: macOS | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
|
||
checksum: | ||
name_template: "checksums.txt" | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package utils | ||
|
||
import ( | ||
"sort" | ||
|
||
"google.golang.org/api/tasks/v1" | ||
) | ||
|
||
func Sort(tasks []*tasks.Task, sortBy string) { | ||
switch sortBy { | ||
case "due": | ||
sort.SliceStable(tasks, func(i, j int) bool { | ||
if tasks[i].Due == "" { | ||
return false | ||
} | ||
|
||
if tasks[j].Due == "" { | ||
return true | ||
} | ||
|
||
return tasks[i].Due < tasks[j].Due | ||
}) | ||
case "title": | ||
sort.SliceStable(tasks, func(i, j int) bool { | ||
return tasks[i].Title < tasks[j].Title | ||
}) | ||
case "position": | ||
default: | ||
sort.SliceStable(tasks, func(i, j int) bool { | ||
return tasks[i].Position < tasks[j].Position && tasks[i].Parent == "" | ||
}) | ||
} | ||
} |