mirror of
https://github.com/onyx-and-iris/vbantxt.git
synced 2025-06-30 15:20:27 +01:00
Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
84ef1904fc | ||
f9ca8a05db | |||
9844d22c46 | |||
|
e7e158981b | ||
b60909e6ec | |||
9a15ad98a8 | |||
b8fa4d5be0 | |||
64c1cb8fbe | |||
eeb789003b | |||
4fd190bc4e | |||
c0aad67199 | |||
be65f41813 | |||
fd72628530 | |||
898fbc3ae2 | |||
5b8219d107 | |||
8ab543df0f | |||
|
2035e158b1 | ||
|
6965b03ae5 | ||
09e4b107bf | |||
c7b9d75ea1 | |||
cc42e928e0 | |||
80a675cc6a | |||
6801d9e4e1 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -17,3 +17,5 @@ bin/
|
||||
|
||||
# Added by goreleaser init:
|
||||
dist/
|
||||
|
||||
.envrc
|
@ -22,8 +22,10 @@ builds:
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
archives:
|
||||
- formats: ['tar.gz']
|
||||
|
27
CHANGELOG.md
27
CHANGELOG.md
@ -11,6 +11,33 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
||||
|
||||
- [x]
|
||||
|
||||
# [0.5.0] - 2025-06-25
|
||||
|
||||
### Added
|
||||
|
||||
- it's now possible to load configuration from environment variables. See [Environment Variables](https://github.com/onyx-and-iris/vbantxt/tree/main?tab=readme-ov-file#environment-variables)
|
||||
- --version/-v command
|
||||
|
||||
### Changed
|
||||
|
||||
- shortname for --host flag is now -H.
|
||||
- shortname for --channel flag is now -n.
|
||||
- toml loader no longer requires a `[connection]` table. See [TOML Config](https://github.com/onyx-and-iris/vbantxt/tree/main?tab=readme-ov-file#toml-config)
|
||||
|
||||
|
||||
# [0.4.1] - 2025-04-05
|
||||
|
||||
### Changed
|
||||
|
||||
- `-loglevel` flag is now of type string. It accepts any one of trace, debug, info, warn, error, fatal or panic.
|
||||
- It defaults to warn.
|
||||
|
||||
# [0.3.1] - 2025-03-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- The CLI now uses `os.UserConfigDir()` to load the default *config.toml*, which should respect `$XDG_CONFIG_HOME`. See [UserConfigDir](https://pkg.go.dev/os#UserConfigDir)
|
||||
|
||||
# [0.2.1] - 2024-11-07
|
||||
|
||||
### Fixed
|
||||
|
122
README.md
122
README.md
@ -7,23 +7,34 @@ Send Voicemeeter/Matrix vban requests.
|
||||
|
||||
For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
||||
|
||||
## Tested against
|
||||
---
|
||||
|
||||
- Basic 1.0.8.4
|
||||
- Banana 2.0.6.4
|
||||
- Potato 3.0.2.4
|
||||
- Matrix 1.0.0.3
|
||||
## Table of Contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [VBANTXT Package](#vbantxt-package)
|
||||
- [VBANTXT CLI](#vbantxt-cli)
|
||||
- [License](#license)
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Voicemeeter](https://voicemeeter.com/) or [Matrix](https://vb-audio.com/Matrix/)
|
||||
- Go 1.18 or greater (if you want to compile yourself, otherwise check `Releases`)
|
||||
- Go 1.18 or greater (a binary is available in [Releases](https://github.com/onyx-and-iris/vbantxt/releases))
|
||||
|
||||
## Tested against
|
||||
|
||||
- Basic 1.1.1.9
|
||||
- Banana 2.1.1.9
|
||||
- Potato 3.1.1.9
|
||||
- Matrix 1.0.1.2
|
||||
|
||||
---
|
||||
|
||||
## `Use`
|
||||
## `VBANTXT Package`
|
||||
|
||||
`go get github.com/onyx-and-iris/vbantxt`
|
||||
```console
|
||||
go get github.com/onyx-and-iris/vbantxt
|
||||
```
|
||||
|
||||
```go
|
||||
package main
|
||||
@ -55,44 +66,91 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
## `Command Line`
|
||||
## `VBANTXT CLI`
|
||||
|
||||
Pass `host`, `port` and `streamname` as flags, for example:
|
||||
### Installation
|
||||
|
||||
```
|
||||
vbantxt -h="gamepc.local" -p=6980 -s=Command1 "strip[0].mute=1 strip[1].mono=1"
|
||||
```console
|
||||
go install github.com/onyx-and-iris/vbantxt/cmd/vbantxt@latest
|
||||
```
|
||||
|
||||
You may also store them in a `config.toml` located in `home directory / .config / vbantxt /`
|
||||
### Use
|
||||
|
||||
A valid `config.toml` might look like this:
|
||||
Simply pass your vban commands as command line arguments:
|
||||
|
||||
```console
|
||||
vbantxt "strip[0].mute=1 strip[1].mono=1"
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### Flags
|
||||
|
||||
```console
|
||||
FLAGS
|
||||
-H, --host STRING VBAN host (default: localhost)
|
||||
-p, --port INT VBAN port (default: 6980)
|
||||
-s, --streamname STRING VBAN stream name (default: Command1)
|
||||
-b, --bps INT VBAN BPS (default: 256000)
|
||||
-n, --channel INT VBAN channel (default: 0)
|
||||
-r, --ratelimit INT VBAN rate limit (ms) (default: 20)
|
||||
-C, --config STRING Path to the configuration file (default: $XDG_CONFIG_HOME/vbantxt/config.toml)
|
||||
-l, --loglevel STRING Log level (debug, info, warn, error, fatal, panic) (default: warn)
|
||||
-v, --version Show version information
|
||||
```
|
||||
|
||||
Pass --host, --port and --streamname as flags on the root command, for example:
|
||||
|
||||
```console
|
||||
vbantxt --host=localhost --port=6980 --streamname=Command1 --help
|
||||
```
|
||||
|
||||
#### Environment Variables
|
||||
|
||||
All flags have corresponding environment variables, prefixed with `VBANTXT_`:
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export VBANTXT_HOST=localhost
|
||||
export VBANTXT_PORT=6980
|
||||
export VBANTXT_STREAMNAME=Command1
|
||||
```
|
||||
|
||||
Flags will override environment variables.
|
||||
|
||||
#### TOML Config
|
||||
|
||||
By default the config loader will look for a config in:
|
||||
|
||||
- $XDG_CONFIG_HOME / vbantxt / config.toml (see [os.UserConfigDir](https://pkg.go.dev/os#UserConfigDir))
|
||||
- A custom config path may be passed with the --config/-C flag.
|
||||
|
||||
All flags have corresponding keys in the config file, for example:
|
||||
|
||||
```toml
|
||||
[connection]
|
||||
host="gamepc.local"
|
||||
port=6980
|
||||
streamname="Command1"
|
||||
```
|
||||
|
||||
- `host` defaults to "localhost"
|
||||
- `port` defaults to 6980
|
||||
- `streamname` defaults to "Command1"
|
||||
|
||||
Command line flags will override values in a config.toml.
|
||||
|
||||
---
|
||||
|
||||
## `Script files`
|
||||
|
||||
The vbantxt-cli utility accepts a single string request or an array of string requests. This means you can pass scripts stored in files.
|
||||
The vbantxt CLI accepts a single string request or an array of string requests. This means you can pass scripts stored in files.
|
||||
|
||||
For example, in Windows with Powershell you could:
|
||||
|
||||
`vbantxt $(Get-Content .\script.txt)`
|
||||
```console
|
||||
vbantxt $(Get-Content .\script.txt)
|
||||
```
|
||||
|
||||
Or with Bash:
|
||||
|
||||
`xargs vbantxt < script.txt`
|
||||
```console
|
||||
xargs vbantxt < script.txt
|
||||
```
|
||||
|
||||
to load commands from a file:
|
||||
|
||||
@ -108,19 +166,18 @@ bus[3].eq.On=0
|
||||
|
||||
Sending commands to VB-Audio Matrix is also possible, for example:
|
||||
|
||||
```
|
||||
vbantxt -s=streamname "Point(ASIO128.IN[2],ASIO128.OUT[1]).dBGain = -8"
|
||||
```console
|
||||
vbantxt "Point(ASIO128.IN[2],ASIO128.OUT[1]).dBGain = -8"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## `Logging`
|
||||
|
||||
The `-log-level` flag allows you to control the verbosity of the application's logging output.
|
||||
The --loglevel/-l flag allows you to control the verbosity of the application's logging output.
|
||||
|
||||
Acceptable values for this flag are:
|
||||
|
||||
- `trace`
|
||||
- `debug`
|
||||
- `info`
|
||||
- `warn`
|
||||
@ -130,8 +187,13 @@ Acceptable values for this flag are:
|
||||
|
||||
For example, to set the log level to `debug`, you can use:
|
||||
|
||||
```
|
||||
vbantxt -s=streamname -log-level=debug "bus[0].eq.on=1 bus[1].gain=-12.8"
|
||||
```console
|
||||
vbantxt --loglevel=debug "bus[0].eq.on=1 bus[1].gain=-12.8"
|
||||
```
|
||||
|
||||
The default log level is `warn` if the flag is not specified.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
`vbantxt` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
||||
|
@ -4,11 +4,11 @@ vars:
|
||||
PROGRAM: vbantxt
|
||||
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
||||
BIN_DIR: bin
|
||||
VERSION:
|
||||
sh: 'git describe --tags $(git rev-list --tags --max-count=1)'
|
||||
|
||||
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
|
||||
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
|
||||
GIT_COMMIT:
|
||||
sh: git log -n 1 --format=%h
|
||||
|
||||
tasks:
|
||||
default:
|
||||
@ -37,12 +37,12 @@ tasks:
|
||||
build-windows:
|
||||
desc: Build the vbantxt project for Windows
|
||||
cmds:
|
||||
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.Version={{.GIT_COMMIT}}" ./cmd/{{.PROGRAM}}/
|
||||
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
|
||||
|
||||
build-linux:
|
||||
desc: Build the vbantxt project for Linux
|
||||
cmds:
|
||||
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.Version={{.GIT_COMMIT}}" ./cmd/{{.PROGRAM}}/
|
||||
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
|
||||
|
||||
test:
|
||||
desc: Run tests
|
||||
|
@ -1,43 +0,0 @@
|
||||
// Package main provides the configuration loading functionality for the vbantxt application.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
Connection connection `toml:"connection"`
|
||||
}
|
||||
|
||||
func (c config) String() string {
|
||||
return fmt.Sprintf(
|
||||
"host: %s port: %d streamname: %s",
|
||||
c.Connection.Host, c.Connection.Port, c.Connection.Streamname)
|
||||
}
|
||||
|
||||
type connection struct {
|
||||
Host string `toml:"host"`
|
||||
Port int `toml:"port"`
|
||||
Streamname string `toml:"streamname"`
|
||||
}
|
||||
|
||||
func loadConfig(configPath string) (*connection, error) {
|
||||
_, err := os.Stat(configPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var config config
|
||||
|
||||
_, err = toml.DecodeFile(configPath, &config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debug(config)
|
||||
|
||||
return &config.Connection, nil
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestLoadConfig_Success(t *testing.T) {
|
||||
conn, err := loadConfig("testdata/config.toml")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, conn.Host, "localhost")
|
||||
assert.Equal(t, conn.Port, 7000)
|
||||
assert.Equal(t, conn.Streamname, "vbantxt")
|
||||
}
|
||||
|
||||
func TestLoadConfig_Errors(t *testing.T) {
|
||||
tt := map[string]struct {
|
||||
input string
|
||||
err string
|
||||
}{
|
||||
"no such file": {
|
||||
input: "/no/such/dir/config.toml",
|
||||
err: "no such file or directory",
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range tt {
|
||||
_, err := loadConfig("/no/such/dir/config.toml")
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
assert.ErrorContains(t, err, tc.err)
|
||||
})
|
||||
}
|
||||
}
|
@ -1,121 +1,106 @@
|
||||
// Package main implements a command-line tool for sending text messages over VBAN using the vbantxt library.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/onyx-and-iris/vbantxt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/peterbourgon/ff/v4"
|
||||
"github.com/peterbourgon/ff/v4/ffhelp"
|
||||
"github.com/peterbourgon/ff/v4/fftoml"
|
||||
)
|
||||
|
||||
type opts struct {
|
||||
host string
|
||||
port int
|
||||
streamname string
|
||||
bps int
|
||||
channel int
|
||||
ratelimit int
|
||||
configPath string
|
||||
loglevel string
|
||||
var version string // Version will be set at build time
|
||||
|
||||
// Flags holds the command-line flags for the VBANTXT client.
|
||||
type Flags struct {
|
||||
Host string
|
||||
Port int
|
||||
Streamname string
|
||||
Bps int
|
||||
Channel int
|
||||
Ratelimit int
|
||||
ConfigPath string // Path to the configuration file
|
||||
Loglevel string // Log level
|
||||
Version bool // Version flag
|
||||
}
|
||||
|
||||
func exit(err error) {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Error: %s", err)
|
||||
func exitOnError(err error) {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
var (
|
||||
host string
|
||||
port int
|
||||
streamname string
|
||||
loglevel string
|
||||
configPath string
|
||||
bps int
|
||||
channel int
|
||||
ratelimit int
|
||||
)
|
||||
var flags Flags
|
||||
|
||||
flag.StringVar(&host, "host", "localhost", "vban host")
|
||||
flag.StringVar(&host, "h", "localhost", "vban host (shorthand)")
|
||||
flag.IntVar(&port, "port", 6980, "vban server port")
|
||||
flag.IntVar(&port, "p", 6980, "vban server port (shorthand)")
|
||||
flag.StringVar(&streamname, "streamname", "Command1", "stream name for text requests")
|
||||
flag.StringVar(&streamname, "s", "Command1", "stream name for text requests (shorthand)")
|
||||
|
||||
flag.IntVar(&bps, "bps", 256000, "vban bps")
|
||||
flag.IntVar(&bps, "b", 256000, "vban bps (shorthand)")
|
||||
flag.IntVar(&channel, "channel", 0, "vban channel")
|
||||
flag.IntVar(&channel, "c", 0, "vban channel (shorthand)")
|
||||
flag.IntVar(&ratelimit, "ratelimit", 20, "request ratelimit in milliseconds")
|
||||
flag.IntVar(&ratelimit, "r", 20, "request ratelimit in milliseconds (shorthand)")
|
||||
// VBAN specific flags
|
||||
fs := ff.NewFlagSet("vbantxt")
|
||||
fs.StringVar(&flags.Host, 'H', "host", "localhost", "VBAN host")
|
||||
fs.IntVar(&flags.Port, 'p', "port", 6980, "VBAN port")
|
||||
fs.StringVar(&flags.Streamname, 's', "streamname", "Command1", "VBAN stream name")
|
||||
fs.IntVar(&flags.Bps, 'b', "bps", 256000, "VBAN BPS")
|
||||
fs.IntVar(&flags.Channel, 'n', "channel", 0, "VBAN channel")
|
||||
fs.IntVar(&flags.Ratelimit, 'r', "ratelimit", 20, "VBAN rate limit (ms)")
|
||||
|
||||
configDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
exit(err)
|
||||
exitOnError(fmt.Errorf("failed to get user config directory: %w", err))
|
||||
}
|
||||
defaultConfigPath := filepath.Join(configDir, "vbantxt", "config.toml")
|
||||
flag.StringVar(&configPath, "config", defaultConfigPath, "config path")
|
||||
flag.StringVar(&configPath, "C", defaultConfigPath, "config path (shorthand)")
|
||||
flag.StringVar(&loglevel, "log-level", "warn", "log level")
|
||||
flag.StringVar(&loglevel, "l", "warn", "log level (shorthand)")
|
||||
|
||||
flag.Parse()
|
||||
// Configuration file and logging flags
|
||||
fs.StringVar(&flags.ConfigPath, 'C', "config", defaultConfigPath, "Path to the configuration file")
|
||||
fs.StringVar(&flags.Loglevel, 'l', "loglevel", "warn", "Log level (debug, info, warn, error, fatal, panic)")
|
||||
fs.BoolVar(&flags.Version, 'v', "version", "Show version information")
|
||||
|
||||
switch loglevel {
|
||||
case "trace":
|
||||
log.SetLevel(log.TraceLevel)
|
||||
case "debug":
|
||||
log.SetLevel(log.DebugLevel)
|
||||
case "info":
|
||||
log.SetLevel(log.InfoLevel)
|
||||
case "warn":
|
||||
log.SetLevel(log.WarnLevel)
|
||||
case "error":
|
||||
log.SetLevel(log.ErrorLevel)
|
||||
case "fatal":
|
||||
log.SetLevel(log.FatalLevel)
|
||||
case "panic":
|
||||
log.SetLevel(log.PanicLevel)
|
||||
default:
|
||||
exit(fmt.Errorf("invalid log level: %s", loglevel))
|
||||
err = ff.Parse(fs, os.Args[1:],
|
||||
ff.WithEnvVarPrefix("VBANTXT"),
|
||||
ff.WithConfigFileFlag("config"),
|
||||
ff.WithConfigAllowMissingFile(),
|
||||
ff.WithConfigFileParser(fftoml.Parser{Delimiter: "."}.Parse),
|
||||
)
|
||||
switch {
|
||||
case errors.Is(err, ff.ErrHelp):
|
||||
fmt.Fprintf(os.Stderr, "%s\n", ffhelp.Flags(fs, "vbantxt [flags] <vban commands>"))
|
||||
os.Exit(0)
|
||||
case err != nil:
|
||||
exitOnError(fmt.Errorf("failed to parse flags: %w", err))
|
||||
}
|
||||
|
||||
o := opts{
|
||||
host: host,
|
||||
port: port,
|
||||
streamname: streamname,
|
||||
bps: bps,
|
||||
channel: channel,
|
||||
ratelimit: ratelimit,
|
||||
configPath: configPath,
|
||||
loglevel: loglevel,
|
||||
if flags.Version {
|
||||
if version == "" {
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
exitOnError(errors.New("failed to read build info"))
|
||||
}
|
||||
version = strings.Split(info.Main.Version, "-")[0]
|
||||
}
|
||||
fmt.Printf("vbantxt version: %s\n", version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Load the config only if the host, port, and streamname flags are not provided.
|
||||
// This allows the user to override the config values with command line flags.
|
||||
if !flagsPassed([]string{"host", "h", "port", "p", "streamname", "s"}) {
|
||||
config, err := loadConfig(configPath)
|
||||
level, err := log.ParseLevel(flags.Loglevel)
|
||||
if err != nil {
|
||||
exit(err)
|
||||
exitOnError(fmt.Errorf("invalid log level: %s", flags.Loglevel))
|
||||
}
|
||||
log.SetLevel(level)
|
||||
|
||||
o.host = config.Host
|
||||
o.port = config.Port
|
||||
o.streamname = config.Streamname
|
||||
}
|
||||
log.Debugf("opts: %+v", o)
|
||||
log.Debugf("Loaded configuration: %+v", flags)
|
||||
|
||||
client, closer, err := createClient(o)
|
||||
client, closer, err := createClient(&flags)
|
||||
if err != nil {
|
||||
exit(err)
|
||||
exitOnError(err)
|
||||
}
|
||||
defer closer()
|
||||
|
||||
for _, arg := range flag.Args() {
|
||||
for _, arg := range fs.GetArgs() {
|
||||
err := client.Send(arg)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
@ -124,14 +109,14 @@ func main() {
|
||||
}
|
||||
|
||||
// createClient creates a new vban client with the provided options.
|
||||
func createClient(o opts) (*vbantxt.VbanTxt, func(), error) {
|
||||
func createClient(flags *Flags) (*vbantxt.VbanTxt, func(), error) {
|
||||
client, err := vbantxt.New(
|
||||
o.host,
|
||||
o.port,
|
||||
o.streamname,
|
||||
vbantxt.WithBPSOpt(o.bps),
|
||||
vbantxt.WithChannel(o.channel),
|
||||
vbantxt.WithRateLimit(time.Duration(o.ratelimit)*time.Millisecond))
|
||||
flags.Host,
|
||||
flags.Port,
|
||||
flags.Streamname,
|
||||
vbantxt.WithBPSOpt(flags.Bps),
|
||||
vbantxt.WithChannel(flags.Channel),
|
||||
vbantxt.WithRateLimit(time.Duration(flags.Ratelimit)*time.Millisecond))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
4
cmd/vbantxt/testdata/config.toml
vendored
4
cmd/vbantxt/testdata/config.toml
vendored
@ -1,4 +0,0 @@
|
||||
[connection]
|
||||
host = "localhost"
|
||||
port = 7000
|
||||
streamname = "vbantxt"
|
@ -1,17 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"slices"
|
||||
)
|
||||
|
||||
func flagsPassed(flags []string) bool {
|
||||
found := false
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
if slices.Contains(flags, f.Name) {
|
||||
found = true
|
||||
return
|
||||
}
|
||||
})
|
||||
return found
|
||||
}
|
25
go.mod
25
go.mod
@ -5,14 +5,31 @@ go 1.23.0
|
||||
toolchain go1.24.1
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.5.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/charmbracelet/log v0.4.2
|
||||
github.com/peterbourgon/ff/v4 v4.0.0-alpha.4
|
||||
github.com/stretchr/testify v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.3.1 // indirect
|
||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.9.3 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/muesli/termenv v0.16.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
63
go.sum
63
go.sum
@ -1,21 +1,56 @@
|
||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/charmbracelet/colorprofile v0.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40=
|
||||
github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0=
|
||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||
github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig=
|
||||
github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw=
|
||||
github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
|
||||
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
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/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
|
||||
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||
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=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/peterbourgon/ff/v4 v4.0.0-alpha.4 h1:aiqS8aBlF9PsAKeMddMSfbwp3smONCn3UO8QfUg0Z7Y=
|
||||
github.com/peterbourgon/ff/v4 v4.0.0-alpha.4/go.mod h1:H/13DK46DKXy7EaIxPhk2Y0EC8aubKm35nBjBe8AAGc=
|
||||
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.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
|
||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
2
makefile
2
makefile
@ -5,7 +5,7 @@ BIN_DIR := bin
|
||||
|
||||
WINDOWS=$(BIN_DIR)/$(PROGRAM)_windows_amd64.exe
|
||||
LINUX=$(BIN_DIR)/$(PROGRAM)_linux_amd64
|
||||
VERSION=$(shell git log -n 1 --format=%h)
|
||||
VERSION=$(shell git describe --tags $(shell git rev-list --tags --max-count=1))
|
||||
|
||||
.DEFAULT_GOAL := build
|
||||
|
||||
|
@ -3,7 +3,7 @@ package vbantxt
|
||||
import (
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
// Option is a functional option type that allows us to configure the VbanTxt.
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -70,5 +70,5 @@ func (p *packet) bumpFrameCounter() {
|
||||
x := binary.LittleEndian.Uint32(p.framecounter)
|
||||
binary.LittleEndian.PutUint32(p.framecounter, x+1)
|
||||
|
||||
log.Tracef("framecounter: %d", x)
|
||||
log.Debugf("framecounter: %d", x)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
// udpConn represents the UDP client.
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/onyx-and-iris/vbantxt"
|
||||
@ -28,14 +29,14 @@ func run(t *testing.T, client *vbantxt.VbanTxt, script []byte) {
|
||||
}
|
||||
|
||||
func TestSendVm(t *testing.T) {
|
||||
client, err := vbantxt.New("localhost", 6980, "onyx")
|
||||
client, err := vbantxt.New(os.Getenv("VBANTXT_HOST"), 6980, os.Getenv("VBANTXT_STREAMNAME"))
|
||||
require.NoError(t, err)
|
||||
|
||||
run(t, client, vm)
|
||||
}
|
||||
|
||||
func TestSendMatrix(t *testing.T) {
|
||||
client, err := vbantxt.New("localhost", 6990, "onyx")
|
||||
client, err := vbantxt.New(os.Getenv("VBANTXT_HOST"), 6990, os.Getenv("VBANTXT_STREAMNAME"))
|
||||
require.NoError(t, err)
|
||||
|
||||
run(t, client, matrix)
|
||||
|
Loading…
x
Reference in New Issue
Block a user