CommandModelOS constructor

CommandModelOS({
  1. required String title,
  2. String? description,
  3. bool external = false,
  4. Function? commonAction,
  5. Function? winAction,
  6. Function? macAction,
  7. Function? linuxAction,
})

Implementation

CommandModelOS({
  required super.title,
  super.description,
  super.external,
  this.commonAction,
  this.winAction,
  this.macAction,
  this.linuxAction,
}) {
  if (commonAction != null) {
    command = commonAction!();
  } else if (Platform.isWindows) {
    if (winAction == null) {
      // fixme: refactor
      // throw AppException(
      //     message: "Action for windows is not defined for $title command");
    }
    command = winAction!();
  } else if (Platform.isMacOS) {
    if (macAction == null) {
      // fixme: refactor
      // throw AppException(
      //     message: "Action for mac is not defined for $title command");
    }
    command = macAction!();
  } else if (Platform.isLinux) {
    if (linuxAction == null) {
      // fixme: refactor
      // throw AppException(
      //     message: "Action for linux is not defined for $title command");
    }
    command = linuxAction!();
  } else {
    // fixme: refactor
    // throw AppException(message: "Invalid OS. Please implement first.");
  }
}