feat: wogihrsoiuvjsroirgj
This commit is contained in:
28
internal/cli/arguments.go
Normal file
28
internal/cli/arguments.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type CLIOptions struct {
|
||||
Input string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
func ParseOptions(args []string) (*CLIOptions, error) {
|
||||
// Parse flags and arguments.
|
||||
verbose := flag.Bool("v", false, "Verbosity. If set, the program will print logs.")
|
||||
flag.Parse()
|
||||
|
||||
if flag.NArg() == 0 {
|
||||
return nil, fmt.Errorf("No input given.")
|
||||
} else if flag.NArg() > 1 {
|
||||
return nil, fmt.Errorf("More than 1 command-line argument.")
|
||||
}
|
||||
|
||||
return &CLIOptions{
|
||||
Input: flag.Arg(0),
|
||||
Verbose: *verbose,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user