@@ -9,18 +9,17 @@ import (
99 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
1010 cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
1111 "github.com/stackitcloud/stackit-cli/internal/pkg/examples"
12- "github.com/stackitcloud/stackit-cli/internal/pkg/flags"
1312 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1413 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1514 "github.com/stackitcloud/stackit-cli/internal/pkg/services/modelexperiments/client"
15+ "github.com/stackitcloud/stackit-cli/internal/pkg/tables"
1616 "github.com/stackitcloud/stackit-cli/internal/pkg/types"
1717
1818 modelexperiments "github.com/stackitcloud/stackit-sdk-go/services/modelexperiments/v1api"
1919)
2020
2121type inputModel struct {
2222 * globalflags.GlobalFlagModel
23- Region string
2423}
2524
2625func NewCmd (params * types.CmdParams ) * cobra.Command {
@@ -65,7 +64,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6564}
6665
6766func configureFlags (cmd * cobra.Command ) {
68- _ = flags .MarkFlagsRequired (cmd , globalflags .RegionFlag )
6967}
7068
7169func parseInput (
@@ -81,7 +79,6 @@ func parseInput(
8179
8280 model := inputModel {
8381 GlobalFlagModel : globalFlags ,
84- Region : flags .FlagToStringValue (p , cmd , globalflags .RegionFlag ),
8582 }
8683
8784 p .DebugInputModel (model )
@@ -97,7 +94,7 @@ func buildListInstancesRequest(
9794 return apiClient .DefaultAPI .ListInstances (
9895 ctx ,
9996 model .ProjectId ,
100- model .Region ,
97+ model .GlobalFlagModel . Region ,
10198 )
10299}
103100
@@ -111,6 +108,23 @@ func outputResult(
111108 }
112109
113110 return p .OutputResult (outputFormat , resp .Instances , func () error {
114- return nil
111+ if len (resp .Instances ) == 0 {
112+ p .Outputf ("No instances found\n " )
113+ return nil
114+ }
115+
116+ table := tables .NewTable ()
117+ table .SetHeader ("ID" , "NAME" , "REGION" , "STATUS" )
118+
119+ for _ , instance := range resp .Instances {
120+ table .AddRow (
121+ instance .Id ,
122+ instance .Name ,
123+ instance .Region ,
124+ instance .State ,
125+ )
126+ }
127+
128+ return table .Display (p )
115129 })
116130}
0 commit comments