This commit is contained in:
abs3nt 2023-01-13 22:27:38 -08:00
parent 1c7249cbca
commit 060532015c
32 changed files with 54 additions and 51 deletions

View File

@ -1,6 +1,8 @@
package main
import "gospt/cmd"
import (
"gospt/src/cmd"
)
func main() {
defCmd := "tui"

View File

@ -10,8 +10,8 @@ import (
"os/exec"
"path/filepath"
"gospt/internal/config"
"gospt/internal/gctx"
"gospt/src/config"
"gospt/src/gctx"
"github.com/zmb3/spotify/v2"
spotifyauth "github.com/zmb3/spotify/v2/auth"

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"os"
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -8,9 +8,9 @@ import (
"path/filepath"
"strings"
"gospt/internal/auth"
"gospt/internal/config"
"gospt/internal/gctx"
"gospt/src/auth"
"gospt/src/config"
"gospt/src/gctx"
"github.com/cristalhq/aconfig"
"github.com/cristalhq/aconfig/aconfigyaml"
@ -45,26 +45,27 @@ func Execute(defCmd string) {
}
func init() {
configDir, _ := os.UserConfigDir()
cfgFile = filepath.Join(configDir, "gospt/client.yml")
cobra.OnInitialize(initConfig)
if !(len(os.Args) > 1) || os.Args[1] != "completion" {
initConfig()
var err error
ctx = gctx.NewContext(context.Background())
client, err = auth.GetClient(ctx)
if err != nil {
panic(err)
}
currentUser, err := client.CurrentUser(ctx)
if err != nil {
panic(err)
}
ctx.UserId = currentUser.ID
cobra.OnInitialize(initClient)
}
func initClient() {
var err error
ctx = gctx.NewContext(context.Background())
client, err = auth.GetClient(ctx)
if err != nil {
panic(err)
}
currentUser, err := client.CurrentUser(ctx)
if err != nil {
panic(err)
}
ctx.UserId = currentUser.ID
}
func initConfig() {
configDir, _ := os.UserConfigDir()
cfgFile = filepath.Join(configDir, "gospt/client.yml")
yamlDecoder := aconfigyaml.New()
loader := aconfig.LoaderFor(&config.Values, aconfig.Config{

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/tui"
"gospt/src/tui"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -4,8 +4,8 @@ import (
"os"
"path/filepath"
"gospt/internal/commands"
"gospt/internal/tui"
"gospt/src/commands"
"gospt/src/tui"
"github.com/spf13/cobra"
)

View File

@ -4,8 +4,8 @@ import (
"os"
"path/filepath"
"gospt/internal/commands"
"gospt/internal/tui"
"gospt/src/commands"
"gospt/src/tui"
"github.com/spf13/cobra"
)

View File

@ -1,7 +1,7 @@
package cmd
import (
"gospt/internal/commands"
"gospt/src/commands"
"github.com/spf13/cobra"
)

View File

@ -11,7 +11,7 @@ import (
"strings"
"time"
"gospt/internal/gctx"
"gospt/src/gctx"
"github.com/zmb3/spotify/v2"
)

View File

@ -3,8 +3,8 @@ package tui
import (
"fmt"
"gospt/internal/commands"
"gospt/internal/gctx"
"gospt/src/commands"
"gospt/src/gctx"
"github.com/zmb3/spotify/v2"
)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"time"
"gospt/internal/commands"
"gospt/src/commands"
"github.com/charmbracelet/bubbles/list"
)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"time"
"gospt/internal/gctx"
"gospt/src/gctx"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"

View File

@ -3,7 +3,7 @@ package tui
import (
"fmt"
"gospt/internal/gctx"
"gospt/src/gctx"
tea "github.com/charmbracelet/bubbletea"
"github.com/zmb3/spotify/v2"

View File

@ -5,8 +5,8 @@ import (
"sync"
"time"
"gospt/internal/commands"
"gospt/internal/gctx"
"gospt/src/commands"
"gospt/src/gctx"
"github.com/charmbracelet/bubbles/list"
"github.com/zmb3/spotify/v2"