Skip to content

Commit

Permalink
feat: improve error message in autocomplete install (scaleway#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Jun 16, 2020
1 parent ac2741a commit c649abd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/namespaces/autocomplete/autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func InstallCommandRun(ctx context.Context, argsI interface{}) (i interface{}, e
defer f.Close()
}
if err != nil {
return nil, err
return nil, installationNotFound(shellName, shellConfigurationFilePath, script.CompleteScript)
}

// Early exit if eval line is already present in the shell configuration.
Expand Down
7 changes: 7 additions & 0 deletions internal/namespaces/autocomplete/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ func installationCancelledError(shellName string, script string) *core.CliError
Hint: fmt.Sprintf("To manually enable autocomplete for %v, run: %v", shellName, script),
}
}

func installationNotFound(shellName string, location string, script string) *core.CliError {
return &core.CliError{
Err: fmt.Errorf("cannot find where to install autocomplete script (tried %s)", location),
Hint: fmt.Sprintf("You can add this line: `%s` in your %s configuration file", script, shellName),
}
}

0 comments on commit c649abd

Please sign in to comment.