Skip to content

Commit

Permalink
cmd/zas: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Jan 17, 2024
1 parent ed2dea6 commit 72b2cdd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 46 deletions.
25 changes: 0 additions & 25 deletions .goreleaser.yml

This file was deleted.

16 changes: 3 additions & 13 deletions cmd/zas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var subcommands = []*zas.Subcommand{
}

var (
verbose, full *bool
cmdInit = zas.NewSubcommand("init", func() {
i := zas.Init{}
i.Run()
Expand All @@ -47,7 +48,6 @@ var (
}
g.Run()
})
verbose, full *bool
)

func init() {
Expand All @@ -69,27 +69,17 @@ func main() {
args = append([]string{"generate"}, args...)
}

var (
command = strings.ToLower(args[0])
found = false
)
command := strings.ToLower(args[0])

for _, cmd := range subcommands {
if cmd.Name == command && cmd.Run != nil {
found = true

cmd.Flag.Parse(args[1:])
cmd.Run()

break
os.Exit(0)
}
}

if found {
// If an internal subcommand is found, we exit.
os.Exit(0)
}

// If not internal subcommand is found, we try to exec an external Zas subcommand (plugin).
cmd := exec.Command(fmt.Sprintf("%s%s", zas.ZAS_PREFIX, args[0]), args[1:]...)
cmd.Stdout = os.Stdout
Expand Down
20 changes: 12 additions & 8 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,22 @@ type ConfigSection map[interface{}]interface{}
* Loads ZAS_CONF_FILE (as defined in constants.go).
* It must be a YAML file.
*/
func NewConfig() (config ConfigSection, err error) {
func NewConfig() (ConfigSection, error) {
data, err := os.ReadFile(ZAS_CONF_FILE)
if err != nil {
return
return nil, err
}
config = make(ConfigSection)
err = yaml.Unmarshal(data, &config)
if err != nil {
return

var config ConfigSection
if err = yaml.Unmarshal(data, &config); err != nil {
return nil, err
}
err = mergo.Merge(&config, ZAS_DEFAULT_CONF)
return

if err = mergo.Merge(&config, ZAS_DEFAULT_CONF); err != nil {
return nil, err
}

return config, nil
}

/*
Expand Down

0 comments on commit 72b2cdd

Please sign in to comment.