(f factory.Factory)
| 44 | } |
| 45 | |
| 46 | func NewCmdView(f factory.Factory) *cobra.Command { |
| 47 | viewFlags := NewViewFlags() |
| 48 | cmd := &cobra.Command{ |
| 49 | Args: usage.ExactArgs(1), |
| 50 | Use: "view {<name> | <id> | <slug>}", |
| 51 | Short: "View a project", |
| 52 | Long: "View a project in Octopus Deploy", |
| 53 | Example: heredoc.Docf(` |
| 54 | %[1]s project view 'Deploy Web App' |
| 55 | %[1]s project view Projects-9000 |
| 56 | %[1]s project view deploy-web-app |
| 57 | `, constants.ExecutableName), |
| 58 | RunE: func(cmd *cobra.Command, args []string) error { |
| 59 | client, err := f.GetSpacedClient(apiclient.NewRequester(cmd)) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | opts := &ViewOptions{ |
| 65 | client, |
| 66 | f.GetCurrentHost(), |
| 67 | cmd.OutOrStdout(), |
| 68 | args[0], |
| 69 | viewFlags, |
| 70 | cmd, |
| 71 | } |
| 72 | |
| 73 | return viewRun(opts) |
| 74 | }, |
| 75 | } |
| 76 | |
| 77 | flags := cmd.Flags() |
| 78 | flags.BoolVarP(&viewFlags.Web.Value, viewFlags.Web.Name, "w", false, "Open in web browser") |
| 79 | |
| 80 | return cmd |
| 81 | } |
| 82 | |
| 83 | func viewRun(opts *ViewOptions) error { |
| 84 | project, err := opts.Client.Projects.GetByIdentifier(opts.idOrName) |
nothing calls this directly
no test coverage detected