All checks were successful
build and deploy kleinTodo / build (push) Successful in 15s
37 lines
624 B
Go
37 lines
624 B
Go
package config
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/BurntSushi/toml"
|
|
"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 {
|
|
configFile, err := ReadConfig()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
if err := toml.NewEncoder(&buf).Encode(configFile); err != nil {
|
|
return err
|
|
}
|
|
|
|
tomlString := buf.String()
|
|
fmt.Println(tomlString)
|
|
return nil
|
|
}
|