Skip to content

Commit

Permalink
Add new commands for Terramate Completer
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRene committed Feb 28, 2024
1 parent dba27f6 commit 711d87d
Show file tree
Hide file tree
Showing 29 changed files with 270 additions and 122 deletions.
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/cloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cloudCmd = &cobra.Command{
Use: "cloud",
Short: "Terramate Cloud commands",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cloudCmd).Standalone()

rootCmd.AddCommand(cloudCmd)
}
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/cloud_drift.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cloud_driftCmd = &cobra.Command{
Use: "drift",
Short: "manage cloud drifts",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cloud_driftCmd).Standalone()

cloudCmd.AddCommand(cloud_driftCmd)
}
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/cloud_drift_show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cloud_drift_showCmd = &cobra.Command{
Use: "show",
Short: "show drifts",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cloud_drift_showCmd).Standalone()

cloud_driftCmd.AddCommand(cloud_drift_showCmd)
}
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/cloud_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cloud_infoCmd = &cobra.Command{
Use: "info",
Short: "cloud information status",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cloud_infoCmd).Standalone()

cloudCmd.AddCommand(cloud_infoCmd)
}
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/cloud_login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cloud_loginCmd = &cobra.Command{
Use: "login",
Short: "login for cloud.terramate.io",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cloud_loginCmd).Standalone()

cloudCmd.AddCommand(cloud_loginCmd)
}
14 changes: 3 additions & 11 deletions completers/terramate_completer/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/terramate"
"github.com/spf13/cobra"
)

Expand All @@ -16,21 +15,14 @@ func init() {
carapace.Gen(createCmd).Standalone()

createCmd.Flags().StringSlice("after", []string{}, "Add a stack as after")
createCmd.Flags().Bool("all-terraform", false, "initialize all Terraform directories containing terraform.backend blocks defined")
createCmd.Flags().StringSlice("before", []string{}, "Add a stack as before")
createCmd.Flags().String("description", "", "Description of the stack, defaults to the stack name")
createCmd.Flags().Bool("ensure-stack-ids", false, "generate an UUID for the stack.id of all stacks which does not define it")
createCmd.Flags().String("id", "", "ID of the stack, defaults to UUID")
createCmd.Flags().Bool("ignore-existing", false, "If the stack already exists do nothing and don't fail")
createCmd.Flags().StringSlice("import", []string{}, "Add import block for the given path on the stack")
createCmd.Flags().String("name", "", "Name of the stack, defaults to stack dir base name")
createCmd.Flags().Bool("no-generate", false, "Disable code generation for the newly created stack")
createCmd.Flags().Bool("no-generate", false, "Disable code generation for the newly created stacks")
rootCmd.AddCommand(createCmd)

carapace.Gen(createCmd).FlagCompletion(carapace.ActionMap{
"after": terramate.ActionStacks().UniqueList(","),
"before": terramate.ActionStacks().UniqueList(","),
})

carapace.Gen(createCmd).PositionalCompletion(
carapace.ActionFiles(),
)
}
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var debugCmd = &cobra.Command{
Use: "debug",
Short: "Terramate debugging commands",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(debugCmd).Standalone()

rootCmd.AddCommand(debugCmd)
}
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/debug_show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var debug_showCmd = &cobra.Command{
Use: "show",
Short: "Show information available in the project",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(debug_showCmd).Standalone()

debugCmd.AddCommand(debug_showCmd)
}
18 changes: 18 additions & 0 deletions completers/terramate_completer/cmd/debug_show_generateOrigins.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var debug_show_generateOriginsCmd = &cobra.Command{
Use: "generate-origins",
Short: "Show generate debug information",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(debug_show_generateOriginsCmd).Standalone()

debug_showCmd.AddCommand(debug_show_generateOriginsCmd)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"github.com/spf13/cobra"
)

var experimental_globalsCmd = &cobra.Command{
var debug_show_globalsCmd = &cobra.Command{
Use: "globals",
Short: "List globals for all stacks",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(experimental_globalsCmd).Standalone()
carapace.Gen(debug_show_globalsCmd).Standalone()

experimentalCmd.AddCommand(experimental_globalsCmd)
debug_showCmd.AddCommand(debug_show_globalsCmd)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"github.com/spf13/cobra"
)

var experimental_metadataCmd = &cobra.Command{
var debug_show_metadataCmd = &cobra.Command{
Use: "metadata",
Short: "Shows metadata available on the project",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(experimental_metadataCmd).Standalone()
carapace.Gen(debug_show_metadataCmd).Standalone()

experimentalCmd.AddCommand(experimental_metadataCmd)
debug_showCmd.AddCommand(debug_show_metadataCmd)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"github.com/spf13/cobra"
)

var experimental_runEnvCmd = &cobra.Command{
Use: "run-env",
var debug_show_runtimeEnvCmd = &cobra.Command{
Use: "runtime-env",
Short: "List run environment variables for all stacks",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(experimental_runEnvCmd).Standalone()
carapace.Gen(debug_show_runtimeEnvCmd).Standalone()

experimentalCmd.AddCommand(experimental_runEnvCmd)
debug_showCmd.AddCommand(debug_show_runtimeEnvCmd)
}
6 changes: 1 addition & 5 deletions completers/terramate_completer/cmd/experimental_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ var experimental_cloneCmd = &cobra.Command{
func init() {
carapace.Gen(experimental_cloneCmd).Standalone()

experimental_cloneCmd.Flags().Bool("skip-child-stacks", false, "Clone ignores child stacks")
experimentalCmd.AddCommand(experimental_cloneCmd)

carapace.Gen(experimental_cloneCmd).PositionalCompletion(
carapace.ActionDirectories(),
carapace.ActionDirectories(),
)
}
18 changes: 0 additions & 18 deletions completers/terramate_completer/cmd/experimental_generate.go

This file was deleted.

18 changes: 0 additions & 18 deletions completers/terramate_completer/cmd/experimental_generate_debug.go

This file was deleted.

4 changes: 0 additions & 4 deletions completers/terramate_completer/cmd/experimental_runGraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ func init() {
experimental_runGraphCmd.Flags().StringP("label", "l", "", "Label used in graph nodes (it could be either \"stack.name\" or \"stack.dir\"")
experimental_runGraphCmd.Flags().StringP("outfile", "o", "", "Output .dot file")
experimentalCmd.AddCommand(experimental_runGraphCmd)

carapace.Gen(experimental_runGraphCmd).FlagCompletion(carapace.ActionMap{
"outfile": carapace.ActionFiles(),
})
}
22 changes: 0 additions & 22 deletions completers/terramate_completer/cmd/experimental_runOrder.go

This file was deleted.

7 changes: 2 additions & 5 deletions completers/terramate_completer/cmd/experimental_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/terramate"
"github.com/spf13/cobra"
)

Expand All @@ -15,10 +14,8 @@ var experimental_triggerCmd = &cobra.Command{
func init() {
carapace.Gen(experimental_triggerCmd).Standalone()

experimental_triggerCmd.Flags().String("cloud-status", "", "Filter by status")
experimental_triggerCmd.Flags().String("experimental-status", "", "Filter by status (Deprecated)")
experimental_triggerCmd.Flags().String("reason", "", "Reason for the stack being triggered")
experimentalCmd.AddCommand(experimental_triggerCmd)

carapace.Gen(experimental_triggerCmd).PositionalCompletion(
terramate.ActionStacks(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,4 @@ func init() {

experimental_vendor_downloadCmd.Flags().StringP("dir", "d", "", "dir to vendor downloaded project")
experimental_vendorCmd.AddCommand(experimental_vendor_downloadCmd)

carapace.Gen(experimental_vendor_downloadCmd).FlagCompletion(carapace.ActionMap{
"dir": carapace.ActionDirectories(),
})

// TODO positional completion
}
1 change: 1 addition & 0 deletions completers/terramate_completer/cmd/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ func init() {
carapace.Gen(fmtCmd).Standalone()

fmtCmd.Flags().Bool("check", false, "Lists unformatted files, exit with 0 if all is formatted, 1 otherwise")
fmtCmd.Flags().Bool("detailed-exit-code", false, "Return an appropriate exit code (0 = ok, 1 = error, 2 = no error but changes were made)")
rootCmd.AddCommand(fmtCmd)
}
1 change: 1 addition & 0 deletions completers/terramate_completer/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ var generateCmd = &cobra.Command{
func init() {
carapace.Gen(generateCmd).Standalone()

generateCmd.Flags().Bool("detailed-exit-code", false, "Return detailed exit code (0 = ok, 1 = errors, 2 = no errors but changes were made")
rootCmd.AddCommand(generateCmd)
}
3 changes: 3 additions & 0 deletions completers/terramate_completer/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var listCmd = &cobra.Command{
func init() {
carapace.Gen(listCmd).Standalone()

listCmd.Flags().String("cloud-status", "", "Filter by status")
listCmd.Flags().String("experimental-status", "", "Filter by status (Deprecated)")
listCmd.Flags().Bool("run-order", false, "Sort stacks by order of execution")
listCmd.Flags().Bool("why", false, "Shows the reason why the stack has changed")
rootCmd.AddCommand(listCmd)
}
Loading

0 comments on commit 711d87d

Please sign in to comment.