Skip to content

Commit

Permalink
Brought in erlcmd, deleted old code.
Browse files Browse the repository at this point in the history
  • Loading branch information
oubiwann committed Nov 27, 2022
1 parent c428f36 commit f16d7e1
Show file tree
Hide file tree
Showing 37 changed files with 101 additions and 1,359 deletions.
3 changes: 2 additions & 1 deletion cmd/midiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (

log "github.com/sirupsen/logrus"

"github.com/geomyidia/erlcmd/pkg/messages"

"github.com/ut-proj/midiserver/internal/app"
"github.com/ut-proj/midiserver/internal/cli"
"github.com/ut-proj/midiserver/pkg/commands"
"github.com/ut-proj/midiserver/pkg/erl/messages"
"github.com/ut-proj/midiserver/pkg/midi"
"github.com/ut-proj/midiserver/pkg/server"
"github.com/ut-proj/midiserver/pkg/types"
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/ut-proj/midiserver
go 1.18

require (
github.com/ergo-services/ergo v1.999.201
github.com/ergo-services/ergo v1.999.220
github.com/geomyidia/erlcmd v0.0.0-20221127192348-aaa9a7cea2f5
github.com/geomyidia/zylog v0.1.5
github.com/google/uuid v1.3.0
github.com/okeuday/erlang_go/v2 v2.0.5
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.5.1
gitlab.com/gomidi/midi v1.23.7
Expand All @@ -16,11 +16,10 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/kr/text v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
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/ergo-services/ergo v1.999.201 h1:mXOkD0Rmw0rvNXdQhvkMjKP7v+IhA6kqMyYxteq+CE8=
github.com/ergo-services/ergo v1.999.201/go.mod h1:iQKxlBMaflSiCV8F+kVeCwwlJxjs78dTuiS8P/Bp/kk=
github.com/ergo-services/ergo v1.999.220 h1:2nS1QSoJQgEThzXYoaC9BSnePxTua39cSbF7CcKCw2I=
github.com/ergo-services/ergo v1.999.220/go.mod h1:uXFQ+bMVZ6R3ygBrQSlaHtx1Bj+cINZo0A8CZ/WYqN4=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/geomyidia/erlcmd v0.0.0-20221127192348-aaa9a7cea2f5 h1:ebFJ9nCf1C/V2Nu5WOBh7hdSrxAOt/SapndGDSlHnno=
github.com/geomyidia/erlcmd v0.0.0-20221127192348-aaa9a7cea2f5/go.mod h1:hm+NKlnHRs/v4PeyGqNCsZcjGhkdxmYWYfWAKQdsj6s=
github.com/geomyidia/zylog v0.1.5 h1:f3FaxDrkCWJDRwiHjsDyA6YMz/EqpUcHHJ55QPEOWc8=
github.com/geomyidia/zylog v0.1.5/go.mod h1:y1pEB+nPevEmbupvHIuT6Znt5gRxah/eJ7dsBgfgbpA=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand All @@ -25,8 +26,6 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/okeuday/erlang_go/v2 v2.0.5 h1:GLv90a/7KhQlDUngcgLyNhP3IbmKnFvA0p2Rq/nLoKc=
github.com/okeuday/erlang_go/v2 v2.0.5/go.mod h1:bUnKKmkI110+DM1rV59zPPqbcXp4yv18Fp2ofRwBmk4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand All @@ -51,7 +50,6 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
46 changes: 23 additions & 23 deletions pkg/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"strconv"

"github.com/ut-proj/midiserver/pkg/erl/datatypes"

"github.com/ergo-services/ergo/etf"
log "github.com/sirupsen/logrus"

"github.com/ut-proj/midiserver/pkg/erl/messages"
"github.com/geomyidia/erlcmd/pkg/messages"

"github.com/ut-proj/midiserver/pkg/text"
"github.com/ut-proj/midiserver/pkg/types"
"github.com/ut-proj/midiserver/pkg/version"
Expand All @@ -22,9 +22,9 @@ func Dispatch(
flags *types.Flags,
) {
log.Debug("Dispatching command ...")
var result types.Result
var err types.Err
if msg.Type() != string(types.CommandKey) {
var result messages.Result
var err messages.Err
if msg.Type() != string(messages.CommandKey) {
log.Error(ErrCmdMsgFormat)
resp := text.NewResponse(result, err)
resp.Send()
Expand All @@ -37,23 +37,23 @@ func Dispatch(
if err != nil {
log.Error(err)
} else {
result = types.OkResult
result = messages.OkResult
}
} else {
result = types.PongResult
result = messages.PongResult
}
case types.PlayNoteCommand():
// TODO: let's put this logic into something that parses the
// playnote message and creates a dedicated struct for
// it
args := make(map[string]interface{})
for _, arg := range msg.Args() {
tuple, ok := arg.(*datatypes.Tuple)
tuple, ok := arg.(etf.Tuple)
if !ok {
log.Error(datatypes.ErrCastingTuple)
log.Error(messages.ErrMsgTupleFormat)
continue
}
args[tuple.Key().(string)] = tuple.Value().(uint)
args[tuple.Element(1).(string)] = tuple.Element(2).(uint)
}
// TODO: if the values aren't in the payload, pull them
// from the flags
Expand All @@ -70,16 +70,16 @@ func Dispatch(
// args["duration"] = toUint(flags.Args[durationIdx])
// }
PlayNote(args)
result = types.OkResult
result = messages.OkResult
case types.ExampleCommand():
args := make(map[string]interface{})
for _, arg := range msg.Args() {
tuple, ok := arg.(*datatypes.Tuple)
tuple, ok := arg.(etf.Tuple)
if !ok {
log.Error(datatypes.ErrCastingTuple)
log.Error(messages.ErrMsgTupleFormat)
continue
}
args[tuple.Key().(string)] = tuple.Value().(uint)
args[tuple.Element(1).(string)] = tuple.Element(2).(uint)
}
// TODO: if the values aren't in the payload, pull them
// from the flags
Expand All @@ -88,26 +88,26 @@ func Dispatch(
// args["channel"] = toUint(flags.Args[2])
// }
PlayExample(args)
result = types.OkResult
result = messages.OkResult
case types.ListDevicesCommand():
ListDevices()
result = types.OkResult
result = messages.OkResult
case types.ListNodesCommand():
ListNodes(flags)
result = types.OkResult
result = messages.OkResult
case types.RemotePortCommand():
ShowRemotePort(flags)
result = types.OkResult
result = messages.OkResult
case types.StopCommand():
log.Info("stopping Go MIDI server ...")
result = types.StoppingResult
result = messages.StoppingResult
<-ctx.Done()
case types.VersionCommand():
result = types.Result(version.VersionedBuildString())
result = messages.Result(version.VersionedBuildString())
case types.EmptyCommand():
result = types.Result("missing command; see -h for useage")
result = messages.Result("missing command; see -h for useage")
default:
result = types.Result(
result = messages.Result(
fmt.Sprintf(
"received unsupported command: '%s' (data: %+v, type: %T)",
cmdName, msg, msg))
Expand Down
23 changes: 0 additions & 23 deletions pkg/erl/datatypes/atom.go

This file was deleted.

39 changes: 0 additions & 39 deletions pkg/erl/datatypes/atom_test.go

This file was deleted.

27 changes: 0 additions & 27 deletions pkg/erl/datatypes/binary.go

This file was deleted.

45 changes: 0 additions & 45 deletions pkg/erl/datatypes/binary_test.go

This file was deleted.

Loading

0 comments on commit f16d7e1

Please sign in to comment.