Skip to content

Commit

Permalink
feat(parameter): update the help and new parameter to show the help
Browse files Browse the repository at this point in the history
  • Loading branch information
anhgelus committed Jun 3, 2023
1 parent 53ff7bc commit bdebc37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This application takes two parameters:
It has also another parameters:
- `-o string` - Set the output file (if it does not give, no output in file)
- `-d (0,1,2)` - Set the difficulty or 0 by default (0 = easy, 1 = hard, 2 = hardcore)
- `-h` - Show the help

## Technologies

Expand Down
15 changes: 13 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ func main() {
height0 := regexp.MustCompile(`-h [0-9]+`)
output0 := regexp.MustCompile(`-o [0-9a-zA-Z/.\-_]+`)
difficulty0 := regexp.MustCompile(`-d [0-9]+`)
help0 := regexp.MustCompile(`-h`)
unWidth := widthO.FindString(cli)
unHeight := height0.FindString(cli)
unOutput := output0.FindString(cli)
unDifficulty := difficulty0.FindString(cli)
t := help0.FindString(cli)
if t != "" {
help()
return
}
if unHeight == "" || unWidth == "" {
help()
return
Expand Down Expand Up @@ -71,6 +77,11 @@ func help() {
println("------------------------------")
println("HELP OF THE MAZE GENERATOR CLI")
println("------------------------------")
println("-w uint -> Width of the maze")
println("-h uint -> Height of the maze")
println("Required arguments:")
println(" -w uint -> Width of the maze")
println(" -h uint -> Height of the maze\n")
println("Optional arguments:")
println(" -d uint -> Difficulty of the maze")
println(" -o string -> Output file of the new maze")

}

0 comments on commit bdebc37

Please sign in to comment.