Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI wonky with readline fix #420

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Binary file added alda-player.exe
Binary file not shown.
Binary file added client/client.exe
Binary file not shown.
24 changes: 12 additions & 12 deletions client/cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"syscall"
"time"

"alda.io/client/color"
"alda.io/client/help"
log "alda.io/client/logging"
"alda.io/client/model"
Expand All @@ -24,6 +23,7 @@ import (
"alda.io/client/transmitter"
"alda.io/client/util"
"github.com/daveyarwood/go-osc/osc"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
"gitlab.com/gomidi/midi/midimessage/channel"
"gitlab.com/gomidi/midi/midireader"
Expand All @@ -33,11 +33,11 @@ const reasonableTimeout = 20 * time.Second

func step(action string, test func() error) error {
if err := test(); err != nil {
fmt.Printf("%s %s\n\n---\n\n", color.Aurora.Red("ERR"), action)
fmt.Printf("%s %s\n\n---\n\n", GookitColor.Red.Render("ERR"), action)
return err
}

fmt.Printf("%s %s\n", color.Aurora.Green("OK "), action)
fmt.Printf("%s %s\n", GookitColor.Green.Render("OK "), action)
return nil
}

Expand Down Expand Up @@ -230,8 +230,8 @@ var doctorCmd = &cobra.Command{
if !text.PromptForConfirmation(
fmt.Sprintf(
"\n%s does not appear to be installed.\nInstall %s now?",
color.Aurora.Bold("alda-player"),
color.Aurora.Bold("alda-player"),
GookitColor.Bold.Render("alda-player"),
GookitColor.Bold.Render("alda-player"),
),
true,
) {
Expand Down Expand Up @@ -273,9 +273,9 @@ var doctorCmd = &cobra.Command{
fmt.Sprintf(
"\nThe versions of %s and %s that you have installed are "+
"different.\nInstall the correct version of %s?",
color.Aurora.Bold("alda"),
color.Aurora.Bold("alda-player"),
color.Aurora.Bold("alda-player"),
GookitColor.Bold.Render("alda"),
GookitColor.Bold.Render("alda-player"),
GookitColor.Bold.Render("alda-player"),
),
true,
) {
Expand All @@ -285,10 +285,10 @@ This might cause unexpected problems.

For best results, run %s and follow the prompt to install the correct
version of %s.`,
color.Aurora.Bold("alda"),
color.Aurora.Bold("alda-player"),
color.Aurora.BrightYellow("alda doctor"),
color.Aurora.Bold("alda-player"),
GookitColor.Bold.Render("alda"),
GookitColor.Bold.Render("alda-player"),
GookitColor.HiYellow.Render("alda doctor"),
GookitColor.Bold.Render("alda-player"),
)
}

Expand Down
6 changes: 3 additions & 3 deletions client/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"path/filepath"
"time"

"alda.io/client/color"
"alda.io/client/help"
log "alda.io/client/logging"
"alda.io/client/model"
"alda.io/client/parser"
"alda.io/client/system"
"alda.io/client/transmitter"
"alda.io/client/util"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -94,8 +94,8 @@ output formats like MusicXML.
`%s is not a supported output format.

Currently, the only supported output format is %s.`,
color.Aurora.BrightYellow(outputFormat),
color.Aurora.BrightYellow("midi"),
GookitColor.HiYellow.Render(outputFormat),
GookitColor.HiYellow.Render("midi"),
)
}

Expand Down
8 changes: 4 additions & 4 deletions client/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"strings"

code_generator "alda.io/client/code-generator"
"alda.io/client/color"
"alda.io/client/help"
"alda.io/client/interop/musicxml/importer"
log "alda.io/client/logging"
"alda.io/client/model"
"alda.io/client/system"
"alda.io/client/transmitter"
"alda.io/client/util"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -80,15 +80,15 @@ Currently, the only import format is MusicXML.
`%s is not a supported input format.

Currently, the only supported output format is %s.`,
color.Aurora.BrightYellow(importFormat),
color.Aurora.BrightYellow("musicxml"),
GookitColor.HiYellow.Render(importFormat),
GookitColor.HiYellow.Render("musicxml"),
)
}

// TODO (experimental): remove warning log
log.Warn().Msg(fmt.Sprintf(
`The %s command is currently experimental. Imported scores may be incorrect and lack information.`,
color.Aurora.BrightYellow("import"),
GookitColor.HiYellow.Render("import"),
))

var scoreUpdates []model.ScoreUpdate
Expand Down
12 changes: 6 additions & 6 deletions client/cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"fmt"
"time"

"alda.io/client/color"
"alda.io/client/help"
"alda.io/client/json"
log "alda.io/client/logging"
"alda.io/client/model"
"alda.io/client/parser"
"alda.io/client/system"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -93,11 +93,11 @@ Please choose one of:
A JSON object representing the score that is constructed after parsing the
source code into events and evaluating them in order within the context of a
new score.`,
color.Aurora.BrightYellow(outputType),
color.Aurora.BrightYellow("ast"),
color.Aurora.BrightYellow("ast-human"),
color.Aurora.BrightYellow("events"),
color.Aurora.BrightYellow("data"),
GookitColor.HiYellow.Render(outputType),
GookitColor.HiYellow.Render("ast"),
GookitColor.HiYellow.Render("ast-human"),
GookitColor.HiYellow.Render("events"),
GookitColor.HiYellow.Render("data"),
)
}

Expand Down
4 changes: 2 additions & 2 deletions client/cmd/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"os"
"time"

"alda.io/client/color"
"alda.io/client/help"
log "alda.io/client/logging"
"alda.io/client/model"
"alda.io/client/parser"
"alda.io/client/system"
"alda.io/client/transmitter"
"alda.io/client/util"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -75,7 +75,7 @@ func parseStdin() (parser.ASTNode, error) {
func sourceCodeInputOptions(command string, useColor bool) string {
maybeColor := func(s string) string {
if useColor {
return fmt.Sprintf("%s", color.Aurora.BrightYellow(s))
return fmt.Sprintf("%s", GookitColor.HiYellow.Render(s))
}

return s
Expand Down
10 changes: 5 additions & 5 deletions client/cmd/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"os/signal"
"syscall"

"alda.io/client/color"
"alda.io/client/help"
"alda.io/client/json"
"alda.io/client/repl"
"alda.io/client/system"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -55,8 +55,8 @@ func errInvalidNREPLMessage(message string) error {
Here is an example of a valid nREPL message:

%s`,
color.Aurora.BgRed(message),
color.Aurora.Bold(`{"op": "eval-and-play", "code": "banjo: c"}`),
GookitColor.BgRed.Render(message),
GookitColor.Bold.Render(`{"op": "eval-and-play", "code": "banjo: c"}`),
)
}

Expand Down Expand Up @@ -107,8 +107,8 @@ connect to it by running:

See %s for more information about starting Alda REPL servers and
clients.`,
color.Aurora.BrightYellow("alda repl --client --port 12345"),
color.Aurora.BrightYellow("alda repl --help"),
GookitColor.HiYellow.Render("alda repl --client --port 12345"),
GookitColor.HiYellow.Render("alda repl --help"),
)

var replCmd = &cobra.Command{
Expand Down
12 changes: 6 additions & 6 deletions client/cmd/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"runtime"
"time"

"alda.io/client/color"
"alda.io/client/generated"
"alda.io/client/help"
log "alda.io/client/logging"
"alda.io/client/system"
"alda.io/client/text"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -120,7 +120,7 @@ If you wish to disable anonymous usage reporting, you can run:

%s`,
telemetryExplanation,
color.Aurora.BrightYellow("alda telemetry --disable"),
GookitColor.HiYellow.Render("alda telemetry --disable"),
),
)+"\n\n",
)
Expand All @@ -146,7 +146,7 @@ func informUserOfTelemetryIfNeeded() {
}

func reportTelemetryStatus(status string) {
fmt.Printf("Telemetry is %s.\n", color.Aurora.Bold(status))
fmt.Printf("Telemetry is %s.\n", GookitColor.Bold.Render(status))
}

func enableTelemetry() error {
Expand Down Expand Up @@ -201,9 +201,9 @@ var telemetryCmd = &cobra.Command{
`%s and %s cannot be used together.

See %s for more information.`,
color.Aurora.BrightYellow("--enable"),
color.Aurora.BrightYellow("--disable"),
color.Aurora.BrightYellow("alda telemetry --help"),
GookitColor.HiYellow.Render("--enable"),
GookitColor.HiYellow.Render("--disable"),
GookitColor.HiYellow.Render("alda telemetry --help"),
)
}

Expand Down
18 changes: 9 additions & 9 deletions client/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
"sync"
"time"

"alda.io/client/color"
"alda.io/client/generated"
"alda.io/client/help"
"alda.io/client/json"
log "alda.io/client/logging"
"alda.io/client/system"
"alda.io/client/text"
"github.com/AlecAivazis/survey/v2"
GookitColor "github.com/gookit/color"
"github.com/spf13/cobra"
"github.com/vbauerster/mpb/v6"
"github.com/vbauerster/mpb/v6/decor"
Expand Down Expand Up @@ -69,9 +69,9 @@ func displayVersionInfo(json *json.Container) {

%s
%s`,
color.Aurora.Bold("Alda "+version),
GookitColor.Bold.Render("Alda "+version),
date,
color.Aurora.Bold("Changelog:"),
GookitColor.Bold.Render("Changelog:"),
text.Indent(1, changelog),
),
),
Expand Down Expand Up @@ -193,7 +193,7 @@ func installAsset(indir string, asset releaseAsset) error {

fmt.Printf(
"%s\n",
color.Aurora.Bold(fmt.Sprintf("Installing %s...", asset.assetName)),
GookitColor.Bold.Render(fmt.Sprintf("Installing %s...", asset.assetName)),
)

// Naïvely, you would think we could simply replace `alda` with the new
Expand Down Expand Up @@ -391,7 +391,7 @@ func installVersion(json *json.Container) error {

fmt.Printf(
"%s",
color.Aurora.Bold(fmt.Sprintf("Downloading Alda %s...\n", versionString(json))),
GookitColor.Bold.Render(fmt.Sprintf("Downloading Alda %s...\n", versionString(json))),
)

return downloadAndInstallAssets(assets)
Expand Down Expand Up @@ -454,7 +454,7 @@ func fetchReleaseInfo(version string) (*json.Container, error) {
case 404:
return nil, help.UserFacingErrorf(
`The requested Alda version, %s, was not found.`,
color.Aurora.Bold(version),
GookitColor.Bold.Render(version),
)
default:
return nil, errUnexpectedAldaApiResponse(response)
Expand All @@ -470,8 +470,8 @@ func promptAndInstallVersion(json *json.Container) error {
if !assumeYes && !text.PromptForConfirmation(
fmt.Sprintf(
"Alda %s is currently installed. Install version %s?",
color.Aurora.Bold(generated.ClientVersion),
color.Aurora.Bold(versionString(json)),
GookitColor.Bold.Render(generated.ClientVersion),
GookitColor.Bold.Render(versionString(json)),
),
true, // default to "yes"
) {
Expand Down Expand Up @@ -499,7 +499,7 @@ func installCorrectAldaPlayerVersion() error {

fmt.Printf(
"%s",
color.Aurora.Bold(fmt.Sprintf("Downloading alda-player %s...\n", version)),
GookitColor.Bold.Render(fmt.Sprintf("Downloading alda-player %s...\n", version)),
)

var aldaPlayerAsset releaseAsset
Expand Down
8 changes: 4 additions & 4 deletions client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ require (
github.com/OpenPeeDeeP/xdg v0.2.0
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/beevik/etree v1.1.0
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
github.com/davecgh/go-spew v1.1.1
github.com/daveyarwood/go-osc v0.0.0-20200229013406-0675d0af5e0b
github.com/dustin/go-humanize v1.0.0
github.com/go-test/deep v1.0.1
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.1.1
github.com/gookit/color v1.5.0
github.com/jackpal/bencode-go v1.0.0
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
github.com/mattn/go-isatty v0.0.8
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/peterh/liner v1.2.2
github.com/rs/zerolog v1.21.0
github.com/spf13/cobra v0.0.5
github.com/vbauerster/mpb/v6 v6.0.2
Expand All @@ -27,16 +28,15 @@ require (

require (
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/chzyer/logex v1.1.10 // indirect
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-runewidth v0.0.10 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect
golang.org/x/text v0.3.3 // indirect
)
Loading