Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Improve no .speechly.yaml error message #60

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/clients/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ func getSpeechlyConfig() (*Config, error) {

if err := viper.ReadInConfig(); err != nil {
if len(os.Args) < 2 || (os.Args[1] != "config" && os.Args[1] != "projects") {
log.Print("Please add a project first:\n\n")
log.Print(" 1. Create a new API token in Speechly Dashboard (https://api.speechly.com/dashboard)\n")
log.Printf(" 2. Copy the token and run: %s projects add --apikey <api_token>\n\n", os.Args[0])
log.Print("Please add a project:\n\n")
log.Print(" 1. Log in to Speechly Dashboard (https://api.speechly.com/dashboard)\n")
log.Printf(" 2. Go to %s and create a new token\n", infoString("Project Settings → API tokens"))
log.Printf(" 2. Copy the token and run: %s\n\n", infoString(fmt.Sprintf("%s projects add <api_token>", os.Args[0])))
log.Print("Learn more: https://docs.speechly.com/dev-tools/command-line-tool")
os.Exit(1)
}
Expand All @@ -92,3 +93,8 @@ func getSpeechlyConfig() (*Config, error) {
}
return &conf, nil
}

func infoString(str string) string {
color := "\033[1;36m%s\033[0m"
return fmt.Sprintf(color, str)
}