ScriptRunnerShellConfig.parse constructor

ScriptRunnerShellConfig.parse(
  1. dynamic obj
)

Parses a shell configuration from a YamlMap, Map or String. Other types will throw a StateError.

Implementation

factory ScriptRunnerShellConfig.parse(dynamic obj) {
  try {
    if (obj is String) {
      return ScriptRunnerShellConfig(defaultShell: obj);
    }
    if (obj is Map || obj is Map) {
      return ScriptRunnerShellConfig(
        defaultShell: obj['default'],
        windows: obj['windows'],
        macos: obj['macos'],
        linux: obj['linux'],
      );
    }
    if (obj == null) {
      return ScriptRunnerShellConfig();
    }
    throw StateError('Invalid shell config: $obj');
  } catch (e) {
    throw StateError('Error while parsing config: $obj');
  }
}