diff --git a/dev/preview/previewctl/cmd/get.go b/dev/preview/previewctl/cmd/get.go index 60d7b5f010d2ae..073b264d3bacbe 100644 --- a/dev/preview/previewctl/cmd/get.go +++ b/dev/preview/previewctl/cmd/get.go @@ -28,6 +28,7 @@ func newGetCmd(logger *logrus.Logger) *cobra.Command { cmd.AddCommand( newGetNameSubCmd(), newGetActiveCmd(logger), + newGetUrlSubCmd(), ) return cmd @@ -52,6 +53,26 @@ func newGetNameSubCmd() *cobra.Command { return cmd } +func newGetUrlSubCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "url", + Short: "", + RunE: func(cmd *cobra.Command, args []string) error { + previewName, err := preview.GetName(branch) + if err != nil { + return err + } + + previewUrl := fmt.Sprintf("https://%s.preview.gitpod-dev.com", previewName) + fmt.Println(previewUrl) + + return nil + }, + } + + return cmd +} + func newGetActiveCmd(logger *logrus.Logger) *cobra.Command { ctx := context.Background()