Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
update flags documentation (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
peakle authored Aug 31, 2022
1 parent 3002df6 commit 6f7721a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ test-projects

dist/
bin
.DS_Store
16 changes: 7 additions & 9 deletions cmd/dcRules/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
)

var (
flagTag string
flagDebug string
flagDebug bool
flagDisable string
flagEnable string
flagRules string
Expand Down Expand Up @@ -50,9 +49,9 @@ var (
)

func init() {
Analyzer.Flags.StringVar(&flagDebug, "d", "", "enable verbose mode for specific rule")
Analyzer.Flags.StringVar(&flagDisable, "disabled", "", "comma-separated list of enabled groups or skip empty to enable everything")
Analyzer.Flags.StringVar(&flagEnable, "enabled", "<all>", "comma-separated list of disabled groups or skip empty to enable everything")
Analyzer.Flags.BoolVar(&flagDebug, "debug", false, "enable verbose mode")
Analyzer.Flags.StringVar(&flagDisable, "disable", "", "comma-separated list of disabled groups or skip empty to enable everything: #perfomance,#experimental")
Analyzer.Flags.StringVar(&flagEnable, "enable", "<all>", "comma-separated list of enabled groups or skip empty to enable everything: #diagnostic,#style")
Analyzer.Flags.StringVar(&flagRules, "rules", "", "comma-separated list of rules files")
}

Expand Down Expand Up @@ -123,13 +122,13 @@ func newEngine() error {
disabledTags["experimental"] = true
}

if flagDebug != "" {
if flagDebug {
debugPrint(fmt.Sprintf("enabled tags: %+v", enabledTags))
debugPrint(fmt.Sprintf("disabled tags: %+v", disabledTags))
}

ctx := &ruleguard.LoadContext{
DebugImports: flagDebug != "",
DebugImports: flagDebug,
Fset: token.NewFileSet(),
DebugPrint: debugPrint,
GroupFilter: func(g *ruleguard.GoRuleGroup) bool {
Expand All @@ -147,7 +146,7 @@ func newEngine() error {
}
}

if flagDebug != "" {
if flagDebug {
if whyDisabled != "" {
debugPrint(fmt.Sprintf("(-) %s is %s", g.Name, whyDisabled))
} else {
Expand Down Expand Up @@ -197,7 +196,6 @@ func runAnalyzer(pass *analysis.Pass) (interface{}, error) {
}

ctx := &ruleguard.RunContext{
Debug: flagDebug,
DebugPrint: debugPrint,
Pkg: pass.Pkg,
Types: pass.TypesInfo,
Expand Down

0 comments on commit 6f7721a

Please sign in to comment.