getAttributes function

Map<String, String> getAttributes(
  1. List<String> arguments,
  2. String parameterName
)

Implementation

Map<String,String> getAttributes(List<String> arguments,String parameterName){


  if(arguments.isEmpty){
    print('\x1B[31mWarning: empty parameters for $parameterName\x1B[0m');
  }

  Map<String,String> attributes = {};

  for (var element in arguments) {
    List<String> splited = element.split(":");
    splited.removeWhere((element) => element.isEmpty); // to remove empty variables; ex => -attr name: or :String

    if(splited.length<2){
      print('\x1B[31mWarning: syntax error at the attribute "$element"\x1B[0m');
      continue;
    }

    attributes[splited[0].trim()]= splited[1].trim();
  }


  return attributes;
}