diff --git a/cmd/vbantxt/config.go b/cmd/vbantxt/config.go deleted file mode 100644 index 748bd0d..0000000 --- a/cmd/vbantxt/config.go +++ /dev/null @@ -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 -} diff --git a/cmd/vbantxt/config_internal_test.go b/cmd/vbantxt/config_internal_test.go deleted file mode 100644 index 7e99c37..0000000 --- a/cmd/vbantxt/config_internal_test.go +++ /dev/null @@ -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) - }) - } -} diff --git a/cmd/vbantxt/testdata/config.toml b/cmd/vbantxt/testdata/config.toml deleted file mode 100644 index 5d0c895..0000000 --- a/cmd/vbantxt/testdata/config.toml +++ /dev/null @@ -1,4 +0,0 @@ -[connection] -host = "localhost" -port = 7000 -streamname = "vbantxt" diff --git a/cmd/vbantxt/util.go b/cmd/vbantxt/util.go deleted file mode 100644 index 399cedb..0000000 --- a/cmd/vbantxt/util.go +++ /dev/null @@ -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 -}