From c971077222622010aa22e551dd5ad852a3e23faa Mon Sep 17 00:00:00 2001 From: Joel Longtine Date: Fri, 18 Feb 2022 14:58:23 -0700 Subject: [PATCH] Remove cmd list Signed-off-by: Joel Longtine --- cmd/dagger/cmd/list.go | 71 ------------------------------------------ cmd/dagger/cmd/root.go | 1 - 2 files changed, 72 deletions(-) delete mode 100644 cmd/dagger/cmd/list.go diff --git a/cmd/dagger/cmd/list.go b/cmd/dagger/cmd/list.go deleted file mode 100644 index ac27b1f0..00000000 --- a/cmd/dagger/cmd/list.go +++ /dev/null @@ -1,71 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - "path" - "strings" - "text/tabwriter" - - "github.com/mitchellh/go-homedir" - "github.com/spf13/cobra" - "github.com/spf13/viper" - "go.dagger.io/dagger/cmd/dagger/cmd/common" - "go.dagger.io/dagger/cmd/dagger/logger" -) - -var listCmd = &cobra.Command{ - Use: "list", - Short: "List available environments", - 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()) - - project := common.CurrentProject(ctx) - doneCh := common.TrackProjectCommand(ctx, cmd, project, nil) - - environments, err := project.List(ctx) - if err != nil { - lg. - Fatal(). - Err(err). - Msg("cannot list environments") - } - - w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.TabIndent) - defer w.Flush() - for _, e := range environments { - line := fmt.Sprintf("%s\t%s\t", e.Name, formatPath(e.Path)) - fmt.Fprintln(w, line) - } - - <-doneCh - }, -} - -func formatPath(p string) string { - dir, err := homedir.Dir() - if err != nil { - // Ignore error - return p - } - - if strings.HasPrefix(p, dir) { - return path.Join("~", p[len(dir):]) - } - return p -} - -func init() { - if err := viper.BindPFlags(listCmd.Flags()); err != nil { - panic(err) - } -} diff --git a/cmd/dagger/cmd/root.go b/cmd/dagger/cmd/root.go index 4629babf..23820e4f 100644 --- a/cmd/dagger/cmd/root.go +++ b/cmd/dagger/cmd/root.go @@ -53,7 +53,6 @@ func init() { rootCmd.AddCommand( initCmd, - listCmd, upCmd, versionCmd, docCmd,