Path: blob/main/components/ide/jetbrains/cli/cmd/open.go
2501 views
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package cmd56import (7"fmt"8"log"9"net/http"10"path/filepath"1112"github.com/spf13/cobra"13)1415var wait bool1617var openCmd = &cobra.Command{18Use: "open",19Args: cobra.ExactArgs(1),20Run: func(cmd *cobra.Command, args []string) {21file, err := filepath.Abs(args[0])22if err != nil {23log.Fatal(err)24}2526url := getCliApiUrl()27query := url.Query()28query.Add("op", "open")29query.Add("file", file)30query.Add("wait", fmt.Sprintf("%t", wait))31url.RawQuery = query.Encode()3233resp, err := http.Get(url.String())34if err != nil {35log.Fatal(err)36}37if resp.StatusCode != http.StatusOK {38log.Fatal(resp.Status)39}40},41}4243func init() {44rootCmd.AddCommand(openCmd)45openCmd.Flags().BoolVar(&wait, "wait", false, "")46}474849