Skip to content

Commit

Permalink
feat: move to coral
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Mar 7, 2022
1 parent 6432c99 commit 6a6b2e0
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 661 deletions.
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ require (
github.com/charmbracelet/lipgloss v0.5.0
github.com/dgraph-io/badger/v3 v3.2103.2
github.com/mattn/go-isatty v0.0.14
github.com/muesli/coral v1.0.0
github.com/muesli/go-app-paths v0.2.2
github.com/muesli/mango-cobra v0.0.0-20220201014606-122d08dcc447
github.com/muesli/mango-coral v1.0.1
github.com/muesli/roff v0.1.0
github.com/spf13/cobra v1.3.0
)

require (
Expand All @@ -32,6 +32,7 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/klauspost/compress v1.12.3 // indirect
Expand All @@ -40,8 +41,8 @@ require (
github.com/microcosm-cc/bluemonday v1.0.17 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/mango v0.0.0-20220201014152-f7df5a1c5b4b // indirect
github.com/muesli/mango-pflag v0.0.0-20220201014449-d694870c5590 // indirect
github.com/muesli/mango v0.1.0 // indirect
github.com/muesli/mango-pflag v0.1.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
Expand All @@ -56,4 +57,5 @@ require (
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
619 changes: 8 additions & 611 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions internal/cmd/completion.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package cmd

import "github.com/spf13/cobra"
import "github.com/muesli/coral"

type completionCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newCompletionCmd() *completionCmd {
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "completion [bash|zsh|fish]",
Short: "Print shell autocompletion scripts for tt",
Long: `To load completions:
Expand All @@ -34,8 +34,8 @@ Fish:
DisableFlagsInUseLine: true,
Hidden: true,
ValidArgs: []string{"bash", "zsh", "fish"},
Args: cobra.ExactValidArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Args: coral.ExactValidArgs(1),
RunE: func(cmd *coral.Command, args []string) error {
var err error
switch args[0] {
case "bash":
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import (
"strings"
"time"

"github.com/spf13/cobra"
"github.com/muesli/coral"
)

type editCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newEditCmd() *editCmd {
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "edit",
Short: "Syntactic sugar for to-json | $EDITOR | from-json",
Aliases: []string{"e"},
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
Args: coral.NoArgs,
RunE: func(cmd *coral.Command, args []string) error {
tmp := filepath.Join(os.TempDir(), fmt.Sprintf("tt-%d.json", time.Now().Unix()))

if err := newToJSONCmd().cmd.RunE(cmd, []string{tmp}); err != nil {
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/fromjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import (

"github.com/caarlos0/tasktimer/internal/model"
"github.com/caarlos0/tasktimer/internal/store"
"github.com/spf13/cobra"
"github.com/muesli/coral"
)

type fromJSONCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newFromJSONCmd() *fromJSONCmd {
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "from-json",
Short: "Imports a JSON into a project - WARNING: it will wipe the project first, use with care!",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Args: coral.ExactArgs(1),
RunE: func(cmd *coral.Command, args []string) error {
project := cmd.Parent().Flag("project").Value.String()
db, f, err := setup(project)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import (

"github.com/charmbracelet/glamour"
"github.com/mattn/go-isatty"
"github.com/muesli/coral"
gap "github.com/muesli/go-app-paths"
"github.com/spf13/cobra"
)

type listCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newListCmd() *listCmd {
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "list",
Short: "List all projects",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
Args: coral.NoArgs,
RunE: func(cmd *coral.Command, args []string) error {
home := gap.NewScope(gap.User, "tasktimer")
datas, err := home.DataDirs()
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/man.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import (
"fmt"
"os"

mcobra "github.com/muesli/mango-cobra"
"github.com/muesli/coral"
mcoral "github.com/muesli/mango-coral"
"github.com/muesli/roff"
"github.com/spf13/cobra"
)

type manCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newManCmd() *manCmd {
root := &manCmd{}
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "man",
Short: "Generates tt's command line manpages",
SilenceUsage: true,
DisableFlagsInUseLine: true,
Hidden: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
manPage, err := mcobra.NewManPageFromCobra(1, root.cmd.Root())
Args: coral.NoArgs,
RunE: func(cmd *coral.Command, args []string) error {
manPage, err := mcoral.NewManPage(1, root.cmd.Root())
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package cmd
import (
"fmt"

"github.com/spf13/cobra"
"github.com/muesli/coral"
)

type pathsCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newPathsCmd() *pathsCmd {
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "paths",
Short: "Print the paths being used for logs, data et al",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
Args: coral.NoArgs,
RunE: func(cmd *coral.Command, args []string) error {
project := cmd.Parent().Flag("project").Value.String()
logfile, dbfile, err := paths(project)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import (
"github.com/caarlos0/tasktimer/internal/ui"
"github.com/charmbracelet/glamour"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
"github.com/muesli/coral"
)

type reportCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newRerportCmd() *reportCmd {
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "report",
Aliases: []string{"r"},
Short: "Print a markdown report of the given project to STDOUT",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
Args: coral.NoArgs,
RunE: func(cmd *coral.Command, args []string) error {
project := cmd.Parent().Flag("project").Value.String()
db, f, err := setup(project)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package cmd
import (
"github.com/caarlos0/tasktimer/internal/ui"
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
"github.com/muesli/coral"
)

func Execute(version string, exit func(int), args []string) {
newRootCmd(version, exit).Execute(args)
}

type rootCmd struct {
cmd *cobra.Command
cmd *coral.Command
project string
exit func(int)
}
Expand All @@ -27,12 +27,12 @@ func newRootCmd(version string, exit func(int)) *rootCmd {
root := &rootCmd{
exit: exit,
}
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "tt",
Short: "Task Timer (tt) is a dead simple TUI task timer",
Version: version,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *coral.Command, args []string) error {
db, f, err := setup(root.project)
if err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/tojson.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import (
"os"

"github.com/caarlos0/tasktimer/internal/ui"
"github.com/spf13/cobra"
"github.com/muesli/coral"
)

type toJSONCmd struct {
cmd *cobra.Command
cmd *coral.Command
}

func newToJSONCmd() *toJSONCmd {
cmd := &cobra.Command{
cmd := &coral.Command{
Use: "to-json",
Short: "Exports the database as JSON",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Args: coral.MaximumNArgs(1),
RunE: func(cmd *coral.Command, args []string) error {
project := cmd.Parent().Flag("project").Value.String()
db, f, err := setup(project)
if err != nil {
Expand Down

0 comments on commit 6a6b2e0

Please sign in to comment.