mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-19 18:12:43 -05:00
remove variable cmd
This commit is contained in:
@@ -96,7 +96,6 @@ func AddCommands() {
|
||||
generateCompletionScriptsCmd(),
|
||||
pluginManagerCmd(),
|
||||
dashboardCmd(),
|
||||
variableCmd(),
|
||||
loginCmd(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
"github.com/turbot/steampipe/pkg/cmdconfig"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/display"
|
||||
"github.com/turbot/steampipe/pkg/error_helpers"
|
||||
"github.com/turbot/steampipe/pkg/workspace"
|
||||
)
|
||||
|
||||
// Variable management commands
|
||||
func variableCmd() *cobra.Command {
|
||||
var cmd = &cobra.Command{
|
||||
Use: "variable [command]",
|
||||
Args: cobra.NoArgs,
|
||||
Short: "Steampipe variable management",
|
||||
Long: `Steampipe variable management.`,
|
||||
}
|
||||
|
||||
cmd.AddCommand(variableListCmd())
|
||||
cmd.Flags().BoolP(constants.ArgHelp, "h", false, "Help for variable")
|
||||
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddModLocationFlag()
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// List variables
|
||||
func variableListCmd() *cobra.Command {
|
||||
var cmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Args: cobra.NoArgs,
|
||||
Run: runVariableListCmd,
|
||||
Short: "List currently installed variables",
|
||||
Long: `List currently installed variables.
|
||||
|
||||
List all Steampipe variables installed for this user.
|
||||
|
||||
Example:
|
||||
|
||||
# List installed variables
|
||||
steampipe variable list
|
||||
|
||||
`,
|
||||
}
|
||||
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddBoolFlag("outdated", false, "Check each variable in the list for updates").
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for variable list", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddModLocationFlag().
|
||||
AddStringFlag(constants.ArgOutput, constants.OutputFormatTable, "Select a console output format: table or json")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runVariableListCmd(cmd *cobra.Command, _ []string) {
|
||||
ctx := cmd.Context()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
error_helpers.ShowError(ctx, helpers.ToError(r))
|
||||
exitCode = constants.ExitCodeUnknownErrorPanic
|
||||
}
|
||||
}()
|
||||
|
||||
// validate output arg
|
||||
output := viper.GetString(constants.ArgOutput)
|
||||
if !helpers.StringSliceContains([]string{constants.OutputFormatTable, constants.OutputFormatJSON}, output) {
|
||||
error_helpers.ShowError(ctx, fmt.Errorf("output flag must be either 'json' or 'table'"))
|
||||
return
|
||||
}
|
||||
|
||||
workspacePath := viper.GetString(constants.ArgModLocation)
|
||||
|
||||
vars, errorsAndWarnings := workspace.LoadVariables(ctx, workspacePath)
|
||||
// load the workspace
|
||||
error_helpers.FailOnErrorWithMessage(errorsAndWarnings.Error, "failed to load workspace")
|
||||
|
||||
if viper.GetString(constants.ArgOutput) == constants.OutputFormatJSON {
|
||||
display.ShowVarsListJson(vars)
|
||||
} else {
|
||||
|
||||
display.ShowVarsListTable(vars)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user