2025-07-19 20:58:05 +02:00
|
|
|
package subcommands
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/DariusKlein/kleinCommand/common"
|
|
|
|
|
"github.com/urfave/cli/v3"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 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 := common.GetConfigPath()
|
|
|
|
|
if err != nil {
|
2025-07-19 22:05:15 +02:00
|
|
|
return err
|
2025-07-19 20:58:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file, err := os.ReadFile(configPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
fmt.Println(string(file))
|
|
|
|
|
return nil
|
|
|
|
|
}
|