Skip to content

Add helper method of checking for a help flag. #69

@digitalghost-dev

Description

@digitalghost-dev

All provided commands are ran through the validation functions in cmd/validateargs.go file.

Currently, in v0.7.0, both the pokemon and types commands are checked for a -h or --help flag in `os.Args[2].

To reduce redundancy, a helper method can be created then used throughout the validation functions. This will continue to provide clean code when new commands are added.

For example:

func handleHelpFlag(args []string) {
  if len(args) == 3 && (args[2] == "-h" || args[2] == "--help") {
    flag.Usage()
  if flag.Lookup("test.v") == nil {
    os.Exit(0)
	}
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprovement to an existing feature.refactorRefactoring existing code.

    Projects

    Status

    Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions