Files
lambda/pkg/cli/arguments.go
2025-12-23 14:17:43 -05:00

28 lines
464 B
Go

package cli
import (
"flag"
"fmt"
"log/slog"
"os"
)
type CLIOptions struct {
Input string
}
func ParseOptions(args []string) (*CLIOptions, error) {
slog.Info("Parsing CLI arguments.", "args", os.Args)
// Parse flags and arguments.
flag.Parse()
switch flag.NArg() {
case 0:
return nil, fmt.Errorf("No input given.")
case 1:
return &CLIOptions{Input: flag.Arg(0)}, nil
default:
return nil, fmt.Errorf("More than 1 command-line argument.")
}
}