Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions cli/cmd/accesstoken.go

This file was deleted.

55 changes: 55 additions & 0 deletions cli/cmd/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package cmd

import (
"github.com/nitrictech/nitric/cli/pkg/app"
"github.com/samber/do/v2"
"github.com/spf13/cobra"
)

// NewLoginCmd creates the login command
func NewLoginCmd(injector do.Injector) *cobra.Command {
return &cobra.Command{
Use: "login",
Short: "Login to Nitric",
Long: `Login to the Nitric CLI.`,
Run: func(cmd *cobra.Command, args []string) {
app, err := do.Invoke[*app.AuthApp](injector)
if err != nil {
cobra.CheckErr(err)
}
app.Login()
},
}
}

// NewLogoutCmd creates the logout command
func NewLogoutCmd(injector do.Injector) *cobra.Command {
return &cobra.Command{
Use: "logout",
Short: "Logout from Nitric",
Long: `Logout from the Nitric CLI.`,
Run: func(cmd *cobra.Command, args []string) {
app, err := do.Invoke[*app.AuthApp](injector)
if err != nil {
cobra.CheckErr(err)
}
app.Logout()
},
}
}

// NewAccessTokenCmd creates the access token command
func NewAccessTokenCmd(injector do.Injector) *cobra.Command {
return &cobra.Command{
Use: "access-token",
Short: "Get access token",
Long: `Get the current access token.`,
Run: func(cmd *cobra.Command, args []string) {
app, err := do.Invoke[*app.AuthApp](injector)
if err != nil {
cobra.CheckErr(err)
}
app.AccessToken()
},
}
}
60 changes: 0 additions & 60 deletions cli/cmd/build.go

This file was deleted.

83 changes: 41 additions & 42 deletions cli/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,55 @@ package cmd
import (
"fmt"

"github.com/charmbracelet/lipgloss"
"github.com/nitrictech/nitric/cli/internal/config"
"github.com/nitrictech/nitric/cli/internal/style"
"github.com/nitrictech/nitric/cli/internal/style/colors"
"github.com/samber/do/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var configSetCmd = &cobra.Command{
Use: "set <key> <value>",
Short: "Set the CLI configuration",
Long: `Set the CLI configuration.`,
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
key := args[0]
value := args[1]

if err := config.SetValue(key, value); err != nil {
fmt.Printf("Error setting config: %v\n", err)
}

if err := config.Save(); err != nil {
fmt.Printf("Error saving config: %v\n", err)
}

fmt.Printf("Config set: %s: %s\n", key, value)
},
}

var configCmd = &cobra.Command{
Use: "config",
Short: "Manage CLI configuration",
Long: `Manage the CLI configuration.`,
Run: func(cmd *cobra.Command, args []string) {
if viper.ConfigFileUsed() != "" {
fmt.Printf("using config file: %s\n", style.Teal(viper.ConfigFileUsed()))
items := config.GetAllConfigItems()

if len(items) > 0 {
fmt.Println("")
// NewConfigCmd creates the config command
func NewConfigCmd(injector do.Injector) *cobra.Command {
configCmd := &cobra.Command{
Use: "config",
Short: "Manage CLI configuration",
Long: `Manage the CLI configuration.`,
Run: func(cmd *cobra.Command, args []string) {
conf := do.MustInvoke[*config.Config](injector)

if conf.FileUsed() != "" {
fmt.Printf("file: %s\n\n", style.Teal(conf.FileUsed()))
fmt.Println(lipgloss.NewStyle().Border(lipgloss.RoundedBorder(), true, false, false, false).BorderForeground(colors.Teal).Render(conf.Dump()))
} else {
fmt.Println("file: none (using defaults)")
}
},
}

configSetCmd := &cobra.Command{
Use: "set <key> <value>",
Short: "Set the CLI configuration",
Long: `Set the CLI configuration.`,
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
key := args[0]
value := args[1]

conf := do.MustInvoke[*config.Config](injector)

if err := conf.SetValue(key, value); err != nil {
fmt.Printf("error setting config: %v", err)
}

for key, value := range items {
fmt.Printf("%s: %s\n", style.Teal(key), value)
if err := conf.Save(); err != nil {
fmt.Printf("error saving config: %v", err)
}
} else {
fmt.Println("config file: none (using defaults)")
}
},
}

func init() {
fmt.Printf("Config set: %s: %s\n", key, value)
},
}

configCmd.AddCommand(configSetCmd)
rootCmd.AddCommand(configCmd)
return configCmd
}
70 changes: 0 additions & 70 deletions cli/cmd/dev.go

This file was deleted.

78 changes: 0 additions & 78 deletions cli/cmd/edit.go

This file was deleted.

Loading
Loading