Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
Implement color prompt #5 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepla authored Mar 27, 2022
1 parent 5e155ea commit 24f347a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ REPL:
if result.Stderr != "" {
fmt.Fprintln(stderr, color.HiRedString(result.Stderr))
}
printPrompt(result)
line.AppendHistory(code)
continue
}

}

// Write history into file
Expand All @@ -215,3 +217,11 @@ func run(code string) (*client.Result, error) {
func ping() (*client.PingResult, error) {
return client.Ping()
}

func printPrompt(result *client.Result) {
fmt.Fprintf(stdout,
"%s %s\n",
color.New(color.FgBlue, color.Bold).Sprint("websh"),
color.New(color.FgCyan, color.Bold).Sprint(result.ElapsedTime),
)
}

0 comments on commit 24f347a

Please sign in to comment.