2025-08-23 19:14:16 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
2026-01-11 21:05:37 +01:00
|
|
|
"bytes"
|
2025-08-23 19:14:16 +02:00
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
|
2026-01-11 21:05:37 +01:00
|
|
|
"github.com/BurntSushi/toml"
|
2025-08-23 19:14:16 +02:00
|
|
|
"github.com/urfave/cli/v3"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// GetConfig Command
|
|
|
|
|
func GetConfig() *cli.Command {
|
|
|
|
|
return &cli.Command{
|
|
|
|
|
Name: "get",
|
|
|
|
|
Usage: "read configuration file",
|
|
|
|
|
Action: getConfigAction,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// getConfigAction logic for GetConfig
|
|
|
|
|
func getConfigAction(context context.Context, c *cli.Command) error {
|
2026-01-11 21:05:37 +01:00
|
|
|
configFile, err := ReadConfig()
|
2025-08-23 19:14:16 +02:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-11 21:05:37 +01:00
|
|
|
var buf bytes.Buffer
|
|
|
|
|
if err := toml.NewEncoder(&buf).Encode(configFile); err != nil {
|
2025-08-23 19:14:16 +02:00
|
|
|
return err
|
|
|
|
|
}
|
2026-01-11 21:05:37 +01:00
|
|
|
|
|
|
|
|
tomlString := buf.String()
|
|
|
|
|
fmt.Println(tomlString)
|
2025-08-23 19:14:16 +02:00
|
|
|
return nil
|
|
|
|
|
}
|