gospt/cmd/tui.go

31 lines
729 B
Go
Raw Normal View History

2023-01-09 23:52:21 +00:00
package cmd
import (
"os"
"path/filepath"
2023-03-10 07:48:02 +00:00
"git.asdf.cafe/abs3nt/gospt/src/tui"
2023-01-09 23:52:21 +00:00
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(tuiCmd)
}
var tuiCmd = &cobra.Command{
Use: "tui",
Short: "Default command, launches the main menu",
Long: `Default command. this is what will run if no other commands are present. Shows the main menu.`,
RunE: func(cmd *cobra.Command, args []string) error {
configDir, _ := os.UserConfigDir()
2023-02-17 22:08:25 +00:00
if commands.ActiveDeviceExists(ctx) {
return tui.StartTea(ctx, commands, "main")
2023-01-11 21:57:47 +00:00
}
2023-01-09 23:52:21 +00:00
if _, err := os.Stat(filepath.Join(configDir, "gospt/device.json")); err != nil {
2023-02-17 22:08:25 +00:00
return tui.StartTea(ctx, commands, "devices")
2023-01-09 23:52:21 +00:00
}
2023-02-17 22:08:25 +00:00
return tui.StartTea(ctx, commands, "main")
2023-01-09 23:52:21 +00:00
},
}