Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions cmd/krakenkey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"bufio"
"context"
"errors"
"flag"
"fmt"
"os"
"runtime"
"strconv"
"strings"
"time"

flag "github.com/spf13/pflag"

"github.com/krakenkey/cli/internal/api"
"github.com/krakenkey/cli/internal/account"
"github.com/krakenkey/cli/internal/auth"
Expand Down Expand Up @@ -49,6 +50,7 @@ func run() int {
// Global flags.
globalFS := flag.NewFlagSet("krakenkey", flag.ContinueOnError)
globalFS.SetOutput(os.Stderr)
globalFS.SetInterspersed(false)
var (
apiURL string
apiKey string
Expand All @@ -71,11 +73,9 @@ func run() int {
}

// --version flag.
if v, _ := globalFS.Lookup("version").Value.(interface{ IsBoolFlag() bool }); v != nil {
if globalFS.Lookup("version").Value.String() == "true" {
fmt.Printf("krakenkey-cli %s\n", version)
return 0
}
if versionFlag, _ := globalFS.GetBool("version"); versionFlag {
fmt.Printf("krakenkey-cli %s\n", version)
return 0
}

remaining := globalFS.Args()
Expand Down Expand Up @@ -166,8 +166,9 @@ func mustInt(fs *flag.FlagSet, s, name string) (int, bool) {
// stringsFlag accumulates repeated flag values (e.g. --san a --san b).
type stringsFlag []string

func (f *stringsFlag) String() string { return strings.Join(*f, ",") }
func (f *stringsFlag) String() string { return strings.Join(*f, ",") }
func (f *stringsFlag) Set(v string) error { *f = append(*f, v); return nil }
func (f *stringsFlag) Type() string { return "value" }

// triBoolFlag is a *bool flag that is nil when not specified.
type triBoolFlag struct{ val *bool }
Expand All @@ -187,6 +188,7 @@ func (f *triBoolFlag) Set(s string) error {
return nil
}
func (f *triBoolFlag) IsBoolFlag() bool { return true }
func (f *triBoolFlag) Type() string { return "bool" }

// ── auth ─────────────────────────────────────────────────────────────────────

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ module github.com/krakenkey/cli
go 1.26

require gopkg.in/yaml.v3 v3.0.1

require github.com/spf13/pflag v1.0.10 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
Loading