@@ -68,15 +68,32 @@ var (
6868 }
6969 },
7070 }
71+
72+ // `tfx project show` command
73+ projectShowCmd = & cobra.Command {
74+ Use : "show" ,
75+ Short : "Show project details" ,
76+ Long : "Show Project in a TFx Organization." ,
77+ RunE : func (cmd * cobra.Command , args []string ) error {
78+ return projectShow (
79+ getTfxClientContext (),
80+ * viperString ("id" ))
81+ },
82+ }
7183)
7284
7385func init () {
7486 // `tfx project list`
7587 projectListCmd .Flags ().StringP ("search" , "s" , "" , "Search string for Project Name (optional)." )
7688 projectListCmd .Flags ().BoolP ("all" , "a" , false , "List All Organizations Projects (optional)." )
7789
90+ // `tfx project show`
91+ projectShowCmd .Flags ().StringP ("id" , "i" , "" , "ID of the project." )
92+ projectShowCmd .MarkFlagRequired ("id" )
93+
7894 rootCmd .AddCommand (projectCmd )
7995 projectCmd .AddCommand (projectListCmd )
96+ projectCmd .AddCommand (projectShowCmd )
8097
8198}
8299
@@ -163,3 +180,36 @@ func projectList(c TfxClientContext, searchString string) error {
163180
164181 return nil
165182}
183+
184+ func projectShow (c TfxClientContext , projectId string ) error {
185+ o .AddMessageUserProvided ("Show Project:" , projectId )
186+ p , err := c .Client .Projects .ReadWithOptions (c .Context , projectId , tfe.ProjectReadOptions {
187+ Include : []tfe.ProjectIncludeOpt {
188+ tfe .ProjectEffectiveTagBindings ,
189+ },
190+ })
191+
192+ if err != nil {
193+ logError (err , "failed to read project" )
194+ }
195+
196+ o .AddDeferredMessageRead ("Name" , p .Name )
197+ o .AddDeferredMessageRead ("ID" , p .ID )
198+ o .AddDeferredMessageRead ("Description" , p .Description )
199+ o .AddDeferredMessageRead ("DefaultExecutionMode" , p .DefaultExecutionMode )
200+
201+ var duration string
202+ if p .AutoDestroyActivityDuration .IsSpecified () {
203+ if duration , err = p .AutoDestroyActivityDuration .Get (); err == nil {
204+ }
205+ }
206+ o .AddDeferredMessageRead ("Auto Destroy Activity Duration" , duration )
207+
208+ tags := make (map [string ]interface {})
209+ for _ , i := range p .EffectiveTagBindings {
210+ tags [i .Key ] = i .Value
211+ }
212+ o .AddDeferredMapMessageRead ("Tags" , tags )
213+
214+ return nil
215+ }
0 commit comments