MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / viewRun

Function viewRun

pkg/cmd/project/view/view.go:83–134  ·  view source on GitHub ↗
(opts *ViewOptions)

Source from the content-addressed store, hash-verified

81}
82
83func viewRun(opts *ViewOptions) error {
84 project, err := opts.Client.Projects.GetByIdentifier(opts.idOrName)
85 if err != nil {
86 return err
87 }
88
89 return output.PrintResource(project, opts.Command, output.Mappers[*projects.Project]{
90 Json: func(p *projects.Project) any {
91 cacBranch := "Not version controlled"
92 if p.IsVersionControlled {
93 cacBranch = p.PersistenceSettings.(projects.GitPersistenceSettings).DefaultBranch()
94 }
95
96 return ProjectAsJson{
97 Id: p.GetID(),
98 Name: p.Name,
99 Slug: p.Slug,
100 Description: p.Description,
101 IsVersionControlled: p.IsVersionControlled,
102 VersionControlBranch: cacBranch,
103 ProjectTags: p.ProjectTags,
104 WebUrl: util.GenerateWebURL(opts.Host, p.SpaceID, fmt.Sprintf("projects/%s", p.GetID())),
105 }
106 },
107 Table: output.TableDefinition[*projects.Project]{
108 Header: []string{"NAME", "SLUG", "DESCRIPTION", "VERSION CONTROL", "TAGS", "WEB URL"},
109 Row: func(p *projects.Project) []string {
110 description := p.Description
111 if description == "" {
112 description = constants.NoDescription
113 }
114
115 cacBranch := "Not version controlled"
116 if p.IsVersionControlled {
117 cacBranch = p.PersistenceSettings.(projects.GitPersistenceSettings).DefaultBranch()
118 }
119
120 return []string{
121 output.Bold(p.Name),
122 p.Slug,
123 description,
124 cacBranch,
125 output.FormatAsList(p.ProjectTags),
126 output.Blue(util.GenerateWebURL(opts.Host, p.SpaceID, fmt.Sprintf("projects/%s", p.GetID()))),
127 }
128 },
129 },
130 Basic: func(p *projects.Project) string {
131 return formatProjectForBasic(opts, p)
132 },
133 })
134}
135
136type ProjectAsJson struct {
137 Id string `json:"Id"`

Callers 1

NewCmdViewFunction · 0.70

Calls 6

PrintResourceFunction · 0.92
GenerateWebURLFunction · 0.92
BoldFunction · 0.92
FormatAsListFunction · 0.92
BlueFunction · 0.92
formatProjectForBasicFunction · 0.85

Tested by

no test coverage detected