Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ide/jetbrains/cli/cmd/root.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
"errors"
9
"log"
10
"net/url"
11
"os"
12
"strconv"
13
14
"github.com/spf13/cobra"
15
)
16
17
var rootCmd = &cobra.Command{
18
Use: "idea-cli",
19
}
20
21
func Execute() {
22
err := rootCmd.Execute()
23
if err != nil {
24
os.Exit(1)
25
}
26
}
27
28
func getCliApiUrl() *url.URL {
29
var backendPort = 63342
30
// TODO look up under alias + qualifier, i.e. intellij or intellij-latest
31
if _, fileStatError := os.Stat("/ide-desktop/bin/idea-cli-dev"); !errors.Is(fileStatError, os.ErrNotExist) {
32
backendPort = backendPort + 1
33
}
34
parsedUrl, urlParseError := url.Parse("http://localhost:" + strconv.Itoa(backendPort) + "/api/gitpod/cli")
35
if urlParseError != nil {
36
log.Fatal(urlParseError)
37
}
38
return parsedUrl
39
}
40
41
func init() {}
42
43