diff --git a/cmd/dagger/cmd/delete.go b/cmd/dagger/cmd/delete.go new file mode 100644 index 00000000..8dbc5bd8 --- /dev/null +++ b/cmd/dagger/cmd/delete.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +var deleteCmd = &cobra.Command{ + Use: "delete", + Short: "Delete a route after taking it offline (WARNING: may destroy infrastructure)", + Args: cobra.NoArgs, + PreRun: func(cmd *cobra.Command, args []string) { + // Fix Viper bug for duplicate flags: + // https://github.com/spf13/viper/issues/233 + if err := viper.BindPFlags(cmd.Flags()); err != nil { + panic(err) + } + }, + Run: func(cmd *cobra.Command, args []string) { + // lg := logger.New() + // ctx := lg.WithContext(cmd.Context()) + + panic("not implemented") + }, +} + +func init() { + if err := viper.BindPFlags(deleteCmd.Flags()); err != nil { + panic(err) + } +} diff --git a/cmd/dagger/cmd/down.go b/cmd/dagger/cmd/down.go index fb0f3dac..e588e999 100644 --- a/cmd/dagger/cmd/down.go +++ b/cmd/dagger/cmd/down.go @@ -1,3 +1,4 @@ +// nolint:dupl package cmd import ( @@ -21,6 +22,7 @@ var downCmd = &cobra.Command{ }, Run: func(cmd *cobra.Command, args []string) { lg := logger.New() + // nolint:staticcheck ctx := lg.WithContext(cmd.Context()) routeName := getRouteName(lg, cmd) @@ -37,9 +39,9 @@ var downCmd = &cobra.Command{ } func init() { - newCmd.Flags().Bool("--no-cache", false, "Disable all run cache") + downCmd.Flags().Bool("--no-cache", false, "Disable all run cache") - if err := viper.BindPFlags(newCmd.Flags()); err != nil { + if err := viper.BindPFlags(downCmd.Flags()); err != nil { panic(err) } } diff --git a/cmd/dagger/cmd/history.go b/cmd/dagger/cmd/history.go new file mode 100644 index 00000000..05104135 --- /dev/null +++ b/cmd/dagger/cmd/history.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +var historyCmd = &cobra.Command{ + Use: "history", + Short: "List past changes to a route", + Args: cobra.NoArgs, + PreRun: func(cmd *cobra.Command, args []string) { + // Fix Viper bug for duplicate flags: + // https://github.com/spf13/viper/issues/233 + if err := viper.BindPFlags(cmd.Flags()); err != nil { + panic(err) + } + }, + Run: func(cmd *cobra.Command, args []string) { + // lg := logger.New() + // ctx := lg.WithContext(cmd.Context()) + + panic("not implemented") + }, +} + +func init() { + if err := viper.BindPFlags(historyCmd.Flags()); err != nil { + panic(err) + } +} diff --git a/cmd/dagger/cmd/login.go b/cmd/dagger/cmd/login.go new file mode 100644 index 00000000..58028c0a --- /dev/null +++ b/cmd/dagger/cmd/login.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +var loginCmd = &cobra.Command{ + Use: "login", + Short: "Login to Dagger Cloud", + Args: cobra.NoArgs, + PreRun: func(cmd *cobra.Command, args []string) { + // Fix Viper bug for duplicate flags: + // https://github.com/spf13/viper/issues/233 + if err := viper.BindPFlags(cmd.Flags()); err != nil { + panic(err) + } + }, + Run: func(cmd *cobra.Command, args []string) { + // lg := logger.New() + // ctx := lg.WithContext(cmd.Context()) + + panic("not implemented") + }, +} + +func init() { + if err := viper.BindPFlags(loginCmd.Flags()); err != nil { + panic(err) + } +} diff --git a/cmd/dagger/cmd/logout.go b/cmd/dagger/cmd/logout.go new file mode 100644 index 00000000..484015d5 --- /dev/null +++ b/cmd/dagger/cmd/logout.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +var logoutCmd = &cobra.Command{ + Use: "logout", + Short: "Logout from Dagger Cloud", + Args: cobra.NoArgs, + PreRun: func(cmd *cobra.Command, args []string) { + // Fix Viper bug for duplicate flags: + // https://github.com/spf13/viper/issues/233 + if err := viper.BindPFlags(cmd.Flags()); err != nil { + panic(err) + } + }, + Run: func(cmd *cobra.Command, args []string) { + // lg := logger.New() + // ctx := lg.WithContext(cmd.Context()) + + panic("not implemented") + }, +} + +func init() { + if err := viper.BindPFlags(logoutCmd.Flags()); err != nil { + panic(err) + } +} diff --git a/cmd/dagger/cmd/query.go b/cmd/dagger/cmd/query.go index a3d39496..e4527e92 100644 --- a/cmd/dagger/cmd/query.go +++ b/cmd/dagger/cmd/query.go @@ -23,6 +23,7 @@ var queryCmd = &cobra.Command{ }, Run: func(cmd *cobra.Command, args []string) { lg := logger.New() + // nolint:staticcheck ctx := lg.WithContext(cmd.Context()) routeName := getRouteName(lg, cmd) @@ -45,14 +46,14 @@ var queryCmd = &cobra.Command{ } func init() { - newCmd.Flags().String("revision", "latest", "Query a specific version of the route") - newCmd.Flags().StringP("format", "f", "", "Output format (json|yaml|cue|text|env)") + queryCmd.Flags().String("revision", "latest", "Query a specific version of the route") + queryCmd.Flags().StringP("format", "f", "", "Output format (json|yaml|cue|text|env)") - newCmd.Flags().BoolP("--no-input", "I", false, "Exclude inputs from query") - newCmd.Flags().BoolP("--no-output", "O", false, "Exclude outputs from query") - newCmd.Flags().BoolP("--no-layout", "L", false, "Exclude outputs from query") + queryCmd.Flags().BoolP("--no-input", "I", false, "Exclude inputs from query") + queryCmd.Flags().BoolP("--no-output", "O", false, "Exclude outputs from query") + queryCmd.Flags().BoolP("--no-layout", "L", false, "Exclude outputs from query") - if err := viper.BindPFlags(newCmd.Flags()); err != nil { + if err := viper.BindPFlags(queryCmd.Flags()); err != nil { panic(err) } } diff --git a/cmd/dagger/cmd/root.go b/cmd/dagger/cmd/root.go index 2bbdf465..31864c98 100644 --- a/cmd/dagger/cmd/root.go +++ b/cmd/dagger/cmd/root.go @@ -29,6 +29,10 @@ func init() { queryCmd, upCmd, downCmd, + deleteCmd, + historyCmd, + loginCmd, + logoutCmd, ) if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil { diff --git a/cmd/dagger/cmd/up.go b/cmd/dagger/cmd/up.go index 833cc7f7..9ee78784 100644 --- a/cmd/dagger/cmd/up.go +++ b/cmd/dagger/cmd/up.go @@ -1,3 +1,4 @@ +// nolint:dupl package cmd import ( @@ -21,6 +22,7 @@ var upCmd = &cobra.Command{ }, Run: func(cmd *cobra.Command, args []string) { lg := logger.New() + // nolint:staticcheck ctx := lg.WithContext(cmd.Context()) routeName := getRouteName(lg, cmd) @@ -39,7 +41,7 @@ var upCmd = &cobra.Command{ func init() { newCmd.Flags().Bool("--no-cache", false, "Disable all run cache") - if err := viper.BindPFlags(newCmd.Flags()); err != nil { + if err := viper.BindPFlags(upCmd.Flags()); err != nil { panic(err) } }