Skip to content

A flexible starting point for a library capable of parsing and validating command line commands with custom arguments, prefixes, commands, etc. each with their own custom validation rules.

Notifications You must be signed in to change notification settings

brandonlenz/command-line-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

command-line-parser

A flexible starting point for a library capable of parsing and validating command line commands with custom arguments, prefixes, commands, etc. each with their own custom validation rules.

Solution.java contains the original problem statement (also below) along with the configuration of the code base to solve tests passed in via the original rule set.

Note that the code base is designed to potentially accomodate custom rules flexibly.

Design a method that parses an input String, s, such that it validates the arguments passed in. The possible commands are as follows:

  • --count An Integer between 10 and 100 (inclusive)
  • --name A String consisting of 3 to 10 characters (inclusive)
  • --help A command indicating the user is requesting help, but has no value following the command

The method should return an int as follows:

  • 1 if the help command is used and all other arguments are valid
  • 0 if all arguments are valid
  • -1 if there are invalid arguments

Rules:

  • Arguments are optional, but at least one valid command must be present
  • Arguments are evaluated in order
  • The help argument takes precedence
  • Arguments are case insensitive
  • "Extra" whitespace is to be ignored

About

A flexible starting point for a library capable of parsing and validating command line commands with custom arguments, prefixes, commands, etc. each with their own custom validation rules.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages