isNameOfVariable method
- String arg
If arg
string is a name of variable and start with '--' then return true
For example, command with next args: dart_app param1 --param2 value2 --param3=value3
Will parse arguments with the method:
isNameOfVariable('param1') - return false isNameOfVariable('--param2') - return true isNameOfVariable('value2') - return false isNameOfVariable('--param3=value3') - return false
Only '--param2' returns true, bacause:
- param1 is argument without value, and not started with '--'
- value2 is a param2 value (is not name), and not started with '--'
- --param3=value3 is varaible name with value, but we waiting only name
Implementation
bool isNameOfVariable(String arg) {
return hasNameAndValue(arg) ? false : argumentWithName.hasMatch(arg);
}