mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
40 lines
887 B
Go
40 lines
887 B
Go
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
// Licensed under the GNU Affero General Public License (AGPL).
|
|
// See License-AGPL.txt in the project root for license information.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "gp",
|
|
Short: "Command line interface for Gitpod",
|
|
}
|
|
|
|
var noColor bool
|
|
|
|
// Execute runs the root command
|
|
func Execute() {
|
|
entrypoint := strings.TrimPrefix(filepath.Base(os.Args[0]), "gp-")
|
|
for _, c := range rootCmd.Commands() {
|
|
if c.Name() == entrypoint {
|
|
// we can't call subcommands directly (they just call their parents - thanks cobra),
|
|
// so instead we have to manipulate the os.Args
|
|
os.Args = append([]string{os.Args[0], entrypoint}, os.Args[1:]...)
|
|
break
|
|
}
|
|
}
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|