|
4 | 4 | "fmt" |
5 | 5 | "net/http" |
6 | 6 | "os" |
| 7 | + "strings" |
7 | 8 |
|
8 | 9 | "github.com/spf13/cobra" |
9 | 10 |
|
@@ -64,20 +65,53 @@ var projectShowCmd = cli.Command{ |
64 | 65 |
|
65 | 66 | func projectShowRun(v cli.Values) (interface{}, error) { |
66 | 67 | mods := []cdsclient.RequestModifier{} |
67 | | - if v.GetString("verbose") == "true" { |
68 | | - mods = append(mods, func(r *http.Request) { |
69 | | - q := r.URL.Query() |
70 | | - q.Set("withApplications", "true") |
71 | | - q.Set("withPipelines", "true") |
72 | | - q.Set("withEnvironments", "true") |
73 | | - r.URL.RawQuery = q.Encode() |
74 | | - }) |
75 | | - } |
| 68 | + mods = append(mods, func(r *http.Request) { |
| 69 | + q := r.URL.Query() |
| 70 | + q.Set("withWorkflowNames", "true") |
| 71 | + q.Set("withIntegrations", "true") |
| 72 | + r.URL.RawQuery = q.Encode() |
| 73 | + }) |
| 74 | + |
76 | 75 | proj, err := client.ProjectGet(v.GetString(_ProjectKey), mods...) |
77 | 76 | if err != nil { |
78 | 77 | return nil, err |
79 | 78 | } |
80 | | - return *proj, nil |
| 79 | + |
| 80 | + var p = struct { |
| 81 | + Key string `cli:"key,key"` |
| 82 | + Name string `cli:"name"` |
| 83 | + Description string `cli:"description"` |
| 84 | + Favorite bool `cli:"favorite"` |
| 85 | + URL string `cli:"url"` |
| 86 | + API string `cli:"api"` |
| 87 | + Workflows string `cli:"workflows"` |
| 88 | + NbWorkflows int `cli:"nb_workflows"` |
| 89 | + RepoManagers string `cli:"repositories_manager"` |
| 90 | + Integrations string `cli:"integration"` |
| 91 | + }{ |
| 92 | + Key: proj.Key, |
| 93 | + Name: proj.Name, |
| 94 | + Description: proj.Description, |
| 95 | + Favorite: proj.Favorite, |
| 96 | + NbWorkflows: len(proj.WorkflowNames), |
| 97 | + Workflows: cli.Ellipsis(strings.Join(proj.WorkflowNames.Names(), ","), 70), |
| 98 | + URL: proj.URLs.UIURL, |
| 99 | + API: proj.URLs.APIURL, |
| 100 | + } |
| 101 | + |
| 102 | + var integrations []string |
| 103 | + for _, inte := range proj.Integrations { |
| 104 | + integrations = append(integrations, inte.Name) |
| 105 | + } |
| 106 | + p.Integrations = cli.Ellipsis(strings.Join(integrations, ","), 70) |
| 107 | + |
| 108 | + var repomanagers []string |
| 109 | + for _, vcs := range proj.VCSServers { |
| 110 | + repomanagers = append(repomanagers, vcs.Name) |
| 111 | + } |
| 112 | + p.RepoManagers = cli.Ellipsis(strings.Join(repomanagers, ","), 70) |
| 113 | + |
| 114 | + return p, nil |
81 | 115 | } |
82 | 116 |
|
83 | 117 | var projectCreateCmd = cli.Command{ |
|
0 commit comments