config download

This commit is contained in:
darius 2024-05-24 19:46:23 +02:00
parent 46dbf59974
commit 186ee99763
3 changed files with 7 additions and 4 deletions

View File

@ -16,12 +16,12 @@ func subcommands() []*cli.Command {
{ {
Name: "create", Name: "create",
Usage: "Generates a new configuration file", Usage: "Generates a new configuration file",
Action: creatAction, Action: CreatAction,
}, },
} }
} }
func creatAction(c *cli.Context) error { func CreatAction(c *cli.Context) error {
var path string var path string
homeDir, _ := os.UserHomeDir() homeDir, _ := os.UserHomeDir()
@ -40,10 +40,11 @@ func creatAction(c *cli.Context) error {
return err return err
} }
client := github.NewClient(nil) client := github.NewClient(nil)
_, _, _, _ = client.Repositories.GetContents(context.Background(), "DariusKlein", "kleinCommand", "config.toml", nil) a1, _, _, _ := client.Repositories.GetContents(context.Background(), "DariusKlein", "kleinCommand", "config.toml", nil)
configPath := filepath.Join(path, "/config.toml") configPath := filepath.Join(path, "/config.toml")
err := os.WriteFile(configPath, []byte(""), 0644) err := os.WriteFile(configPath, []byte(*a1.Content), 0644)
if err != nil { if err != nil {
return err return err
} }

View File

@ -0,0 +1 @@
test123

View File

@ -12,6 +12,7 @@ import (
) )
func main() { func main() {
config.CreatAction(&cli.Context{})
app := &cli.App{ app := &cli.App{
Name: "KleinCommand", Name: "KleinCommand",
Usage: "manage your home server", Usage: "manage your home server",