Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ide/jetbrains/cli/cmd/preview.go
2501 views
1
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package cmd
6
7
import (
8
"log"
9
"net/http"
10
11
"github.com/spf13/cobra"
12
)
13
14
var previewCmd = &cobra.Command{
15
Use: "preview",
16
Run: func(cmd *cobra.Command, args []string) {
17
url := getCliApiUrl()
18
query := url.Query()
19
query.Add("op", "preview")
20
query.Add("url", args[0])
21
url.RawQuery = query.Encode()
22
23
resp, err := http.Get(url.String())
24
if err != nil {
25
log.Fatal(err)
26
}
27
if resp.StatusCode != http.StatusOK {
28
log.Fatal(resp.Status)
29
}
30
},
31
}
32
33
func init() {
34
rootCmd.AddCommand(previewCmd)
35
}
36
37