34 lines
537 B
Go
34 lines
537 B
Go
|
|
package config
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
"os"
|
||
|
|
|
||
|
|
"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 {
|
||
|
|
_, configPath, err := GetConfigPath()
|
||
|
|
if err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
file, err := os.ReadFile(configPath)
|
||
|
|
if err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
fmt.Println(string(file))
|
||
|
|
return nil
|
||
|
|
}
|