Skip to content

Commit

Permalink
Config init
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Dec 13, 2022
1 parent 29c5629 commit adde1e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (c *CLI) configCmd() *cobra.Command {
c.Fail(fmt.Sprintf("cannot initialize config: %s", err))
return
}
c.SetOutput("path", c.config.File())
c.Ok("config initialized properly")
},
})
Expand Down
13 changes: 9 additions & 4 deletions pkg/cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,21 @@ func (c *Config) ConfigureLogger() {
var configYml string

func (c *Config) Init() error {
if osx.PathExists(FileName) {
return fmt.Errorf("config file already exists: '%s'", FileName)
file := c.File()
if osx.PathExists(file) {
return fmt.Errorf("config file already exists: '%s'", file)
}
err := osx.FileWrite(FileName, configYml)
err := osx.FileWrite(file, configYml)
if err != nil {
return fmt.Errorf("cannot create initial config file: '%s'", FileName)
return fmt.Errorf("cannot create initial config file '%s': '%w'", file, err)
}
return nil
}

func (c *Config) File() string {
return filePath() + "/" + FileName
}

const (
InputStdin string = "STDIN"
OutputFile string = "aem/home/aem.log"
Expand Down

0 comments on commit adde1e7

Please sign in to comment.