Skip to content

Commit 59f1420

Browse files
authored
Merge pull request #106 from section/bug/wsl2-error-message
error messages about adding sectionctl_token to path now work for wsl2.
2 parents 14634c0 + 18efdae commit 59f1420

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

commands/login.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,28 @@ type LoginCmd struct {
1919

2020
// Run executes the command
2121
func (c *LoginCmd) Run() (err error) {
22+
screenshot := "https://raw.githubusercontent.com/section/sectionctl/main/docs/section_token_control_panel.png"
23+
windowsStr := fmt.Sprintf("Unable to write credential.\n\nPlease execute the following, add it to your Powershell profile, or add it to your environment variables in control panel: \nWith Powershell:\n$env:SECTION_TOKEN=\"%s\"\n\nWith CMD:\nset SECTION_TOKEN=%s\n\nWith control panel:\n%s", api.Token, api.Token, screenshot)
24+
linuxStr := fmt.Sprintf("Unable to write credential.\n\nPlease run this command, and add it to your ~/.bashrc (you do not need to run sectionctl login again)\n\nexport SECTION_TOKEN=%s", api.Token)
2225
if api.Token != "" {
2326
err = credentials.Write(api.PrefixURI.Host, api.Token)
2427
if err != nil {
25-
if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
26-
fmt.Printf("Unable to write credential.\n\nPlease run this command, and add it to your ~/.bashrc\n\nexport SECTION_TOKEN=%s\n",api.Token)
27-
return nil
28-
} else if runtime.GOOS == "windows" {
29-
screenshot := "https://raw.githubusercontent.com/section/sectionctl/main/docs/section_token_control_panel.png"
30-
fmt.Printf("Unable to write credential.\n\nPlease execute the following, add it to your Powershell profile, or add it to your environment variables in control panel: \nWith Powershell:\n$env:SECTION_TOKEN=\"%s\"\n\nWith CMD:\nset SECTION_TOKEN=%s\n\nWith control panel:\n%s",api.Token,api.Token,screenshot)
28+
if runtime.GOOS == "windows" {
29+
fmt.Print(windowsStr)
3130
return nil
3231
}
33-
return fmt.Errorf("unable to write credential: %w", err)
32+
fmt.Printf("%s\n", linuxStr)
33+
return nil
3434
}
3535
} else {
3636
t, err := credentials.PromptAndWrite(c.In(), c.Out(), api.PrefixURI.Host)
3737
if err != nil {
38-
return fmt.Errorf("unable to prompt and write credentials: %w", err)
38+
if runtime.GOOS == "windows" {
39+
fmt.Printf("Unable to write credential.\n\nPlease execute the following, add it to your Powershell profile, or add it to your environment variables in control panel: \nWith Powershell:\n$env:SECTION_TOKEN=\"%s\"\n\nWith CMD:\nset SECTION_TOKEN=%s\n\nWith control panel:\n%s", t, t, screenshot)
40+
return nil
41+
}
42+
fmt.Printf("%s%s\n", linuxStr, t)
43+
return nil
3944
}
4045
api.Token = t
4146
}

0 commit comments

Comments
 (0)