Skip to content

Commit

Permalink
add example to examples/basic
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Aug 7, 2023
1 parent d0f37e9 commit 6bebe11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# IDE Settings
/.idea
/.vscode
/.vs
/.vs

examples/basic/basic
examples/basic/basic.exe
10 changes: 9 additions & 1 deletion examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Options struct {
fileSize goflags.Size
duration time.Duration
rls goflags.RateLimitMap
severity []string
}

func main() {
Expand All @@ -37,6 +38,7 @@ func main() {
flagSet.CallbackVarP(CheckUpdate, "update", "ut", "update this tool to latest version"),
flagSet.SizeVarP(&testOptions.fileSize, "max-size", "ms", "", "max file size"),
flagSet.DurationVar(&testOptions.duration, "timeout", time.Hour, "timeout"),
flagSet.EnumSliceVarP(&testOptions.severity, "severity", "s", []goflags.EnumVariable{2}, "severity of the scan", goflags.AllowdTypes{"low": goflags.EnumVariable(0), "medium": goflags.EnumVariable(1), "high": goflags.EnumVariable(2)}),
)
flagSet.SetCustomHelpText("EXAMPLE USAGE:\ngo run ./examples/basic [OPTIONS]")

Expand All @@ -45,5 +47,11 @@ func main() {
}

// ratelimits value is
fmt.Printf("Got RateLimits: %+v\n", testOptions.rls)
if len(testOptions.rls.AsMap()) > 0 {
fmt.Printf("Got RateLimits: %+v\n", testOptions.rls)
}

if len(testOptions.severity) > 0 {
fmt.Printf("Got Severity: %+v\n", testOptions.severity)
}
}

0 comments on commit 6bebe11

Please sign in to comment.