Skip to content

Commit

Permalink
refactor: Move option init into struct declaration
Browse files Browse the repository at this point in the history
Signed-off-by: AlexNg <contact@ngjx.org>
  • Loading branch information
caffeine-addictt committed Aug 30, 2024
1 parent 921f0ca commit 0d2c202
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
21 changes: 21 additions & 0 deletions cmd/options/global.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
package options

import (
"fmt"

"github.com/caffeine-addictt/template/cmd/utils"
"github.com/caffeine-addictt/template/cmd/utils/types"
)

// The global options for the CLI
var GlobalOpts = GlobalOptions{
Debug: false,
Verbose: false,
Repo: *types.NewValueGuardNoParsing("", "<repo>"),
CacheDir: *types.NewValueGuard("", func(v string) (string, error) {
ok, err := utils.IsDir(v)
if err != nil {
return "", err
}

if !ok {
return "", fmt.Errorf("'%s' is not a valid directory", v)
}

return v, nil
}, "<path>"),
}

type GlobalOptions struct {
// The repository Url to use
// Should be this repository by default
Expand Down
27 changes: 0 additions & 27 deletions cmd/options/root.go

This file was deleted.

0 comments on commit 0d2c202

Please sign in to comment.