diff --git a/alda-player.exe b/alda-player.exe new file mode 100644 index 00000000..78c2f7f2 Binary files /dev/null and b/alda-player.exe differ diff --git a/client/client.exe b/client/client.exe new file mode 100644 index 00000000..ddbdae5d Binary files /dev/null and b/client/client.exe differ diff --git a/client/cmd/doctor.go b/client/cmd/doctor.go index 2e72dc03..72ae0baa 100644 --- a/client/cmd/doctor.go +++ b/client/cmd/doctor.go @@ -13,7 +13,6 @@ import ( "syscall" "time" - "alda.io/client/color" "alda.io/client/help" log "alda.io/client/logging" "alda.io/client/model" @@ -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" @@ -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 } @@ -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, ) { @@ -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, ) { @@ -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"), ) } diff --git a/client/cmd/export.go b/client/cmd/export.go index cb9842cf..735f32e8 100644 --- a/client/cmd/export.go +++ b/client/cmd/export.go @@ -9,7 +9,6 @@ import ( "path/filepath" "time" - "alda.io/client/color" "alda.io/client/help" log "alda.io/client/logging" "alda.io/client/model" @@ -17,6 +16,7 @@ import ( "alda.io/client/system" "alda.io/client/transmitter" "alda.io/client/util" + GookitColor "github.com/gookit/color" "github.com/spf13/cobra" ) @@ -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"), ) } diff --git a/client/cmd/import.go b/client/cmd/import.go index 46c06b9e..37cada86 100644 --- a/client/cmd/import.go +++ b/client/cmd/import.go @@ -6,7 +6,6 @@ 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" @@ -14,6 +13,7 @@ import ( "alda.io/client/system" "alda.io/client/transmitter" "alda.io/client/util" + GookitColor "github.com/gookit/color" "github.com/spf13/cobra" ) @@ -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 diff --git a/client/cmd/parse.go b/client/cmd/parse.go index bdbdcb26..10913a18 100644 --- a/client/cmd/parse.go +++ b/client/cmd/parse.go @@ -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" ) @@ -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"), ) } diff --git a/client/cmd/play.go b/client/cmd/play.go index c196ba5a..f3c9f614 100644 --- a/client/cmd/play.go +++ b/client/cmd/play.go @@ -5,7 +5,6 @@ import ( "os" "time" - "alda.io/client/color" "alda.io/client/help" log "alda.io/client/logging" "alda.io/client/model" @@ -13,6 +12,7 @@ import ( "alda.io/client/system" "alda.io/client/transmitter" "alda.io/client/util" + GookitColor "github.com/gookit/color" "github.com/spf13/cobra" ) @@ -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 diff --git a/client/cmd/repl.go b/client/cmd/repl.go index 76c406fb..a6f533fd 100644 --- a/client/cmd/repl.go +++ b/client/cmd/repl.go @@ -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" ) @@ -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"}`), ) } @@ -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{ diff --git a/client/cmd/telemetry.go b/client/cmd/telemetry.go index 6dff0149..fc9353dd 100644 --- a/client/cmd/telemetry.go +++ b/client/cmd/telemetry.go @@ -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" ) @@ -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", ) @@ -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 { @@ -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"), ) } diff --git a/client/cmd/update.go b/client/cmd/update.go index c52d4a86..95c9d51f 100644 --- a/client/cmd/update.go +++ b/client/cmd/update.go @@ -13,7 +13,6 @@ import ( "sync" "time" - "alda.io/client/color" "alda.io/client/generated" "alda.io/client/help" "alda.io/client/json" @@ -21,6 +20,7 @@ import ( "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" @@ -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), ), ), @@ -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 @@ -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) @@ -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) @@ -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" ) { @@ -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 diff --git a/client/go.mod b/client/go.mod index 5cb52245..000200d6 100644 --- a/client/go.mod +++ b/client/go.mod @@ -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 @@ -27,8 +28,6 @@ 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 @@ -36,7 +35,8 @@ require ( 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 ) diff --git a/client/go.sum b/client/go.sum index e95a6b03..62ef81a9 100644 --- a/client/go.sum +++ b/client/go.sum @@ -14,17 +14,12 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat6 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= -github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/daveyarwood/go-osc v0.0.0-20200229013406-0675d0af5e0b h1:7Fw67Bi/cmrgvVt/ZAoVy6Lhmt3AeDutl/ksbil/gkY= @@ -38,6 +33,8 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaU github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw= +github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= @@ -56,6 +53,7 @@ github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= @@ -65,6 +63,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw= +github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -83,14 +83,18 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6 github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/vbauerster/mpb/v6 v6.0.2 h1:DWFnBOcgHi9GUNduC1MbQ936Z7B77wvOnZexP9Hjzcw= github.com/vbauerster/mpb/v6 v6.0.2/go.mod h1:JDNVbdx4oAMMxZNXodDH2DeDY5xBJC8bDGHNFZwRqQM= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= gitlab.com/gomidi/midi v1.14.1 h1:+I3MHxspu3H1o2ejAdehBLmIUBTOIdlOlmkdKvCJlME= @@ -114,8 +118,10 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 h1:kwrAHlwJ0DUBZwQ238v+Uod/3eZ8B2K5rYsUHBQvzmI= +golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -127,3 +133,5 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/client/help/errors.go b/client/help/errors.go index a819aa19..1e3fed9d 100644 --- a/client/help/errors.go +++ b/client/help/errors.go @@ -5,8 +5,8 @@ import ( "os" "strings" - "alda.io/client/color" "alda.io/client/text" + GookitColor "github.com/gookit/color" "github.com/spf13/cobra" ) @@ -62,7 +62,7 @@ func (ue *UsageError) Error() string { return fmt.Sprintf( "%s\n\n---\n\nUsage error:\n\n%s\n", strings.TrimRight(ue.Cmd.UsageString(), "\n"), - color.Aurora.Red(text.Indent(1, strings.TrimRight(ue.Err.Error(), "\n"))), + GookitColor.Red.Render(text.Indent(1, strings.TrimRight(ue.Err.Error(), "\n"))), ) } @@ -84,9 +84,9 @@ This might be a bug. For help, consider filing an issue at: Or come chat with us on Slack: %s`+"\n", - color.Aurora.BgRed(err), - color.Aurora.Underline("https://github.com/alda-lang/alda/issues/new/choose"), - color.Aurora.Underline("https://slack.alda.io"), + GookitColor.BgRed.Render(err), + GookitColor.OpUnderscore.Render("https://github.com/alda-lang/alda/issues/new/choose"), + GookitColor.OpUnderscore.Render("https://slack.alda.io"), ) } } diff --git a/client/interop/musicxml/importer/handlers.go b/client/interop/musicxml/importer/handlers.go index f864c9d2..fe79357b 100644 --- a/client/interop/musicxml/importer/handlers.go +++ b/client/interop/musicxml/importer/handlers.go @@ -7,11 +7,11 @@ import ( "strconv" "strings" - "alda.io/client/color" log "alda.io/client/logging" "alda.io/client/model" "github.com/beevik/etree" "github.com/go-test/deep" + GookitColor "github.com/gookit/color" ) // elementHandler is a function that can handle the import of a MusicXML element @@ -77,15 +77,15 @@ func unsupportedHandler(elementName string, isPlanned bool) elementHandler { log.Warn().Msg(fmt.Sprintf( `%s with the <%s> tag are currently not supported for MusicXML import. We plan to add support for importing %s in the future.`, - color.Aurora.BrightYellow(elementName), - color.Aurora.BrightYellow(element.Tag), - color.Aurora.BrightYellow(elementName), + GookitColor.HiYellow.Render(elementName), + GookitColor.HiYellow.Render(element.Tag), + GookitColor.HiYellow.Render(elementName), )) } else { log.Warn().Msg(fmt.Sprintf( `%s with the <%s> tag are not supported for MusicXML import.`, - color.Aurora.BrightYellow(elementName), - color.Aurora.BrightYellow(element.Tag), + GookitColor.HiYellow.Render(elementName), + GookitColor.HiYellow.Render(element.Tag), )) } } diff --git a/client/interop/musicxml/importer/importer.go b/client/interop/musicxml/importer/importer.go index dc08dc76..beebb17a 100644 --- a/client/interop/musicxml/importer/importer.go +++ b/client/interop/musicxml/importer/importer.go @@ -4,9 +4,9 @@ import ( "io" "sort" - "alda.io/client/color" "alda.io/client/help" "github.com/beevik/etree" + GookitColor "github.com/gookit/color" "alda.io/client/model" ) @@ -362,13 +362,13 @@ func ImportMusicXML(r io.Reader) ([]model.ScoreUpdate, error) { if scorePartwise == nil && scoreTimewise != nil { return nil, help.UserFacingErrorf( `Issue importing MusicXML file: please convert to %s instead of %s using XSLT before importing`, - color.Aurora.BrightYellow("score-partwise"), - color.Aurora.BrightYellow("score-timewise"), + GookitColor.HiYellow.Render("score-partwise"), + GookitColor.HiYellow.Render("score-timewise"), ) } else if scorePartwise == nil { return nil, help.UserFacingErrorf( `Issue importing MusicXML file: could not last %s root tag`, - color.Aurora.BrightYellow("score-partwise"), + GookitColor.HiYellow.Render("score-partwise"), ) } diff --git a/client/model/score.go b/client/model/score.go index 66be3b1c..db8883b2 100644 --- a/client/model/score.go +++ b/client/model/score.go @@ -4,9 +4,9 @@ import ( "regexp" "strconv" - "alda.io/client/color" "alda.io/client/help" "alda.io/client/json" + GookitColor "github.com/gookit/color" ) // The ScoreUpdate interface is implemented by events that update a score. @@ -186,9 +186,9 @@ func (score *Score) InterpretOffsetReference( Valid offset references include: • A minute-and-second time marking (e.g. %s) • The name of a marker in the score (e.g. %s)`, - color.Aurora.BrightYellow(reference), - color.Aurora.BrightYellow("0:30"), - color.Aurora.BrightYellow("verse2"), + GookitColor.HiYellow.Render(reference), + GookitColor.HiYellow.Render("0:30"), + GookitColor.HiYellow.Render("verse2"), ) } diff --git a/client/parser/parser.go b/client/parser/parser.go index e903fad7..37f7cb44 100644 --- a/client/parser/parser.go +++ b/client/parser/parser.go @@ -7,10 +7,10 @@ import ( "os" "time" - "alda.io/client/color" "alda.io/client/help" log "alda.io/client/logging" model "alda.io/client/model" + GookitColor "github.com/gookit/color" ) type parser struct { @@ -1129,7 +1129,7 @@ func ParseFile(filepath string) (ASTNode, error) { `Failed to open %s. The file does not seem to exist. Please check that you haven't misspelled the file name, etc.`, - color.Aurora.BrightYellow(filepath), + GookitColor.HiYellow.Render(filepath), ) } diff --git a/client/repl/client.go b/client/repl/client.go index fd353bf0..8857ce63 100644 --- a/client/repl/client.go +++ b/client/repl/client.go @@ -12,7 +12,6 @@ import ( "strings" "time" - "alda.io/client/color" "alda.io/client/generated" "alda.io/client/help" "alda.io/client/json" @@ -20,10 +19,11 @@ import ( "alda.io/client/parser" "alda.io/client/system" "alda.io/client/util" - "github.com/chzyer/readline" "github.com/google/shlex" "github.com/google/uuid" + GookitColor "github.com/gookit/color" bencode "github.com/jackpal/bencode-go" + "github.com/peterh/liner" ) const aldaASCIILogo = ` @@ -583,9 +583,9 @@ Is there an Alda REPL server running on that port? If not, you can start one by running: %s`, - color.Aurora.Bold(client.serverAddr), - color.Aurora.BgRed(err), - color.Aurora.BrightYellow( + GookitColor.Bold.Render(client.serverAddr), + GookitColor.BgRed.Render(err), + GookitColor.HiYellow.Render( fmt.Sprintf("alda repl --server --port %d", client.serverAddr.Port), ), ) @@ -1063,9 +1063,9 @@ func RunClient(serverHost string, serverPort int) error { fmt.Printf( "%s\n\n%s\n\n%s\n\n", - color.Aurora.Blue(strings.Trim(aldaASCIILogo, "\n")), - color.Aurora.Cyan(strings.Trim(aldaVersionText(serverVersion), "\n")), - color.Aurora.Bold("Type :help for a list of available commands."), + GookitColor.Blue.Render(strings.Trim(aldaASCIILogo, "\n")), + GookitColor.Cyan.Render(strings.Trim(aldaVersionText(serverVersion), "\n")), + GookitColor.Bold.Render("Type :help for a list of available commands."), ) err = os.MkdirAll(filepath.Dir(replHistoryFilepath), os.ModePerm) @@ -1073,15 +1073,7 @@ func RunClient(serverHost string, serverPort int) error { return err } - console, err := readline.NewEx(&readline.Config{ - Prompt: "alda> ", - InterruptPrompt: "^C", - EOFPrompt: "^D", - HistoryFile: replHistoryFilepath, - }) - if err != nil { - return err - } + console := liner.NewLiner() switch serverHost { case "localhost", "127.0.0.1", "0.0.0.0": @@ -1089,13 +1081,22 @@ func RunClient(serverHost string, serverPort int) error { } defer console.Close() + console.SetCtrlCAborts(true) - log.SetOutput(console.Stderr()) + // need to test multiLineMode + console.SetMultiLineMode(true) + // os.Stderr for now, need to handle consoles Stderr + log.SetOutput(os.Stderr) for client.running { - line, err := console.Readline() - if err == readline.ErrInterrupt { + if f, err := os.Open(replHistoryFilepath); err == nil { + console.ReadHistory(f) + f.Close() + } + + line, err := console.Prompt("alda> ") + if err == liner.ErrInvalidPrompt { if len(line) == 0 { break } else { @@ -1113,6 +1114,11 @@ func RunClient(serverHost string, serverPort int) error { input := strings.TrimSpace(line) + if f, err := os.OpenFile(replHistoryFilepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil { + f.WriteString(line + "\n") + f.Close() + } + if strings.HasPrefix(input, ":") && len(input) > 1 { re := regexp.MustCompile(`^:([^ ]+) ?(.*)$`) captured := re.FindStringSubmatch(input) diff --git a/client/system/process_management.go b/client/system/process_management.go index a590b548..88b0f7e4 100644 --- a/client/system/process_management.go +++ b/client/system/process_management.go @@ -11,11 +11,11 @@ import ( "strings" "time" - "alda.io/client/color" "alda.io/client/generated" "alda.io/client/help" log "alda.io/client/logging" "alda.io/client/util" + GookitColor "github.com/gookit/color" "github.com/daveyarwood/go-osc/osc" ) @@ -297,12 +297,12 @@ The %s command-line client needs to spawn %s processes in order to play audio in the background. To install %s, run %s and answer %s when prompted.`, - color.Aurora.Bold("alda-player"), - color.Aurora.Bold("alda"), - color.Aurora.Bold("alda-player"), - color.Aurora.Bold("alda-player"), - color.Aurora.BrightYellow("alda doctor"), - color.Aurora.Bold("y"), + GookitColor.Bold.Render("alda-player"), + GookitColor.Bold.Render("alda"), + GookitColor.Bold.Render("alda-player"), + GookitColor.Bold.Render("alda-player"), + GookitColor.HiYellow.Render("alda doctor"), + GookitColor.Bold.Render("y"), ) playerLogFile := CachePath("logs", "alda-player.log") @@ -326,11 +326,11 @@ To troubleshoot: • Try to make it play something: %s`, - color.Aurora.BrightYellow("alda doctor"), - color.Aurora.BrightYellow("alda ps"), - color.Aurora.BrightYellow(playerLogFile), - color.Aurora.BrightYellow("alda-player -v run -p 27278"), - color.Aurora.BrightYellow("alda -v2 play -p 27278 -c \"piano: c12 e g > c4\""), + GookitColor.HiYellow.Render("alda doctor"), + GookitColor.HiYellow.Render("alda ps"), + GookitColor.HiYellow.Render(playerLogFile), + GookitColor.HiYellow.Render("alda-player -v run -p 27278"), + GookitColor.HiYellow.Render("alda -v2 play -p 27278 -c \"piano: c12 e g > c4\""), ) } @@ -440,10 +440,10 @@ To list the current player processes, you can run %s. You can also omit the %s / %s option, and Alda will find a player process for you automatically.`, - color.Aurora.BrightYellow(id), - color.Aurora.BrightYellow("alda ps"), - color.Aurora.BrightYellow("-i"), - color.Aurora.BrightYellow("--player-id"), + GookitColor.HiYellow.Render(id), + GookitColor.HiYellow.Render("alda ps"), + GookitColor.HiYellow.Render("-i"), + GookitColor.HiYellow.Render("--player-id"), ) }