Option.from constructor

Option.from(
  1. String name,
  2. List<String> params
)

Options from name and params E.g "l" , ["10"]

Implementation

factory Option.from(String name, List<String> params) {
  try {
    Option _set(Option option) {
      try {
        return option
          ..name = name
          ..params = params
          .._buildOption();
      } on Exception {
        rethrow;
      }
    }

    if (name == "d" || name == "u") {
      return _set(DuplicateOption());
    } else if (name == "l") {
      return _set(LengthOption._());
    } else if (name == "s") {
      return _set(StartOption());
    } else if (name == "e") {
      return _set(EndOption());
    } else if (name == "<") {
      return _set(NotStartOption());
    } else if (name == ">") {
      return _set(NotEndOption());
    } else if (name == "c") {
      return _set(ConsecutiveOptions());
    }

    throw FormatException("Option $name not found.");
  } on Exception {
    rethrow;
  }
}