-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(refactor) cmd refactor #22
Conversation
CoverItUp Report
Commits HistoryUpto Users HistoryUpto |
main.go
Outdated
} | ||
|
||
func wantsVersion() { | ||
if f.version { | ||
if len(os.Args) == 2 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func wantsVersion() {
- if len(os.Args) == 2 &&
- (os.Args[1] == "-version" || os.Args[1] == "--version" ||
- os.Args[1] == "-v" || os.Args[1] == "--v" ||
- os.Args[1] == "version") || f.version {
- fmt.Println(version)
- os.Exit(0)
- }
+ if len(os.Args) != 2 {
+ return
+ }
+ switch os.Args[1] {
+ case "-v", "--v", "-version", "--version":
+ fmt.Println(version)
+ os.Exit(0)
+ }
}
Thanks @ccoVeille |
I'm glad you find my review useful |
Co-authored-by: ccoVeille <[email protected]>
Co-authored-by: ccoVeille <[email protected]>
} | ||
|
||
// provide a Set() method on the type so we can use it with flag.Var | ||
func (i *SliceFlags) Set(value string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't be append, reverting back from append -> set
Reason:
./main.go:201:11: cannot use &f.filePaths (value of type *"github.com/kevincobain2000/gol/pkg".SliceFlags) as flag.Value value in argument to flag.Var: *"github.com/kevincobain2000/gol/pkg".SliceFlags does not implement flag.Value (missing method Set)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, in such case, I always try to add a comment like:
// required to implement flag.Value interface
CoverItUp ReportComparison Table - 8 Types 📈
Commits HistoryUpto Users HistoryUpto |
CoverItUp ReportComparison Table - 8 Types 📈
Commits HistoryUpto Users HistoryUpto |
CoverItUp ReportComparison Table - 8 Types 📈
Commits HistoryUpto Users HistoryUpto |
pkg/files.go
Outdated
@@ -383,3 +383,10 @@ func UniqueFileInfos(fileInfos []FileInfo) []FileInfo { | |||
} | |||
return list | |||
} | |||
|
|||
// func UniqueFileInfos(fileInfos []FileInfo) []FileInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You kept them here for a later use ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed them. I tested the asis and Tobe first, as there were no tests for that.
Refactoring first as part of #1