Skip to content

Commit e4e77a4

Browse files
committed
merge upstream
2 parents 151eb2b + a48f107 commit e4e77a4

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

cmd/ghcs/code.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import (
1313
)
1414

1515
func NewCodeCmd() *cobra.Command {
16-
return &cobra.Command{
16+
useInsiders := false
17+
18+
codeCmd := &cobra.Command{
1719
Use: "code [<codespace>]",
1820
Short: "Open a Codespace in VS Code",
1921
Args: cobra.MaximumNArgs(1),
@@ -22,16 +24,20 @@ func NewCodeCmd() *cobra.Command {
2224
if len(args) > 0 {
2325
codespaceName = args[0]
2426
}
25-
return Code(codespaceName)
27+
return Code(codespaceName, useInsiders)
2628
},
2729
}
30+
31+
codeCmd.Flags().BoolVar(&useInsiders, "insiders", false, "Use the insiders version of VS Code")
32+
33+
return codeCmd
2834
}
2935

3036
func init() {
3137
rootCmd.AddCommand(NewCodeCmd())
3238
}
3339

34-
func Code(codespaceName string) error {
40+
func Code(codespaceName string, useInsiders bool) error {
3541
apiClient := api.New(os.Getenv("GITHUB_TOKEN"))
3642
ctx := context.Background()
3743

@@ -51,13 +57,17 @@ func Code(codespaceName string) error {
5157
codespaceName = codespace.Name
5258
}
5359

54-
if err := open.Run(vscodeProtocolURL(codespaceName)); err != nil {
60+
if err := open.Run(vscodeProtocolURL(codespaceName, useInsiders)); err != nil {
5561
return fmt.Errorf("error opening vscode URL")
5662
}
5763

5864
return nil
5965
}
6066

61-
func vscodeProtocolURL(codespaceName string) string {
62-
return fmt.Sprintf("vscode://github.codespaces/connect?name=%s", url.QueryEscape(codespaceName))
67+
func vscodeProtocolURL(codespaceName string, useInsiders bool) string {
68+
application := "vscode"
69+
if useInsiders {
70+
application = "vscode-insiders"
71+
}
72+
return fmt.Sprintf("%s://github.codespaces/connect?name=%s", application, url.QueryEscape(codespaceName))
6373
}

cmd/ghcs/create.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ func Create(opts *CreateOptions) error {
9898
}
9999
}
100100

101-
log.Printf("Codespace created: %s\n", codespace.Name)
101+
log.Printf("Codespace created: ")
102+
103+
fmt.Fprintln(os.Stdout, codespace.Name)
102104

103105
return nil
104106
}

0 commit comments

Comments
 (0)