Open SeriyBg opened 7 years ago
In parser you will have to split string like this commandString.split(" --")
and you will receive arrays of string with values {"create", "name CoolName", "description Description"}
In this array firs element type="create"
. To parse arguments use .split(" ")
and on each argument where first element will be key of map and second element will be value for map.
1) Create a class named
RawCommand
with fieldsString type
andMap<String, String> arguments
. 2) Create parser forRawCommand
namedCommandParser
. For now you handle commands likecreate
but you have to handlecreate --name CoolName --description Description
.CommandParser
will parse this string and and create a newRawCommand
withtype=create
andargs="name":"CoolName" "description":"Description"