github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/cli/commands/resources/application/query.go (about) 1 package application 2 3 import ( 4 "github.com/taubyte/tau-cli/cli/common" 5 "github.com/taubyte/tau-cli/flags" 6 applicationPrompts "github.com/taubyte/tau-cli/prompts/application" 7 applicationTable "github.com/taubyte/tau-cli/table/application" 8 "github.com/urfave/cli/v2" 9 ) 10 11 func (link) Query() common.Command { 12 return common.Create( 13 &cli.Command{ 14 Flags: []cli.Flag{ 15 flags.List, 16 flags.Select, 17 }, 18 Action: query, 19 }, 20 ) 21 } 22 23 func (link) List() common.Command { 24 return common.Create( 25 &cli.Command{ 26 Action: list, 27 }, 28 ) 29 } 30 31 func query(ctx *cli.Context) error { 32 if ctx.Bool(flags.List.Name) { 33 return list(ctx) 34 } 35 36 // If --select is set we should not check the user's currently selected application 37 checkEnv := !ctx.Bool(flags.Select.Name) 38 39 application, err := applicationPrompts.GetOrSelect(ctx, checkEnv) 40 if err != nil { 41 return err 42 } 43 44 applicationTable.Query(application) 45 46 return nil 47 }