Skip to content

Commit 9760328

Browse files
committed
fix lint issues
Signed-off-by: Victoria Nadasdi <[email protected]>
1 parent 91351ba commit 9760328

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

internal/cmd/error.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,16 @@ func (e CommandError) Error() string {
2121
func resourceNotFoundError(name string) CommandError {
2222
return CommandError{Message: name + " does not exist"}
2323
}
24+
25+
// FlagError is an error during flag parsing.
26+
type FlagError struct {
27+
Message string
28+
}
29+
30+
func (e FlagError) Error() string {
31+
return "flag error: %s" + e.Message
32+
}
33+
34+
func invalidAlgorithmError(value string) FlagError {
35+
return FlagError{Message: "Invalid algorithm: " + value}
36+
}

internal/cmd/flags.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package cmd
22

33
import (
4-
"fmt"
5-
64
"github.com/urfave/cli/v2"
75
"github.com/yitsushi/totp-cli/internal/storage"
86
)
@@ -12,9 +10,9 @@ func flagAlgorithm() *cli.StringFlag {
1210
Name: "algorithm",
1311
Value: "sha1",
1412
Usage: "Algorithm to use for HMAC (sha1, sha256, sha512).",
15-
Action: func(ctx *cli.Context, value string) error {
13+
Action: func(_ *cli.Context, value string) error {
1614
if value != "sha1" && value != "sha256" && value != "sha512" {
17-
return fmt.Errorf("Invalid algorithm: %s", value)
15+
return invalidAlgorithmError(value)
1816
}
1917

2018
return nil

internal/storage/account.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const DefaultTokenLength = 6
66

77
// Account represents a TOTP account.
88
type Account struct {
9-
Name string `json:"name" yaml:"name"`
10-
Token string `json:"token" yaml:"token"`
11-
Prefix string `json:"prefix" yaml:"prefix"`
12-
Length uint `json:"length" yaml:"length"`
9+
Name string `json:"name" yaml:"name"`
10+
Token string `json:"token" yaml:"token"`
11+
Prefix string `json:"prefix" yaml:"prefix"`
12+
Length uint `json:"length" yaml:"length"`
1313
Algorithm string `json:"algorithm" yaml:"algorithm"`
1414
}

0 commit comments

Comments
 (0)