From 186ee99763426ce02b09b7cd2eabeb4f78d5bb41 Mon Sep 17 00:00:00 2001 From: darius Date: Fri, 24 May 2024 19:46:23 +0200 Subject: [PATCH] config download --- commands/config/subcommands.go | 9 +++++---- config.toml | 1 + main.go | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/commands/config/subcommands.go b/commands/config/subcommands.go index 35227ed..30c56f0 100644 --- a/commands/config/subcommands.go +++ b/commands/config/subcommands.go @@ -16,12 +16,12 @@ func subcommands() []*cli.Command { { Name: "create", 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 homeDir, _ := os.UserHomeDir() @@ -40,10 +40,11 @@ func creatAction(c *cli.Context) error { return err } 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") - err := os.WriteFile(configPath, []byte(""), 0644) + err := os.WriteFile(configPath, []byte(*a1.Content), 0644) if err != nil { return err } diff --git a/config.toml b/config.toml index e69de29..0c759a4 100644 --- a/config.toml +++ b/config.toml @@ -0,0 +1 @@ +test123 \ No newline at end of file diff --git a/main.go b/main.go index f389052..f48c3bc 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( ) func main() { + config.CreatAction(&cli.Context{}) app := &cli.App{ Name: "KleinCommand", Usage: "manage your home server",