fromJson static method
Parses one schema entry reported by ext.nylo.commands.list.
Implementation
static LiveCommandOption? fromJson(Object? json) {
if (json is! Map) return null;
final Object? name = json['name'];
if (name is! String || name.isEmpty) return null;
final Object? abbr = json['abbr'];
final Object? help = json['help'];
final Object? allowed = json['allowed'];
return LiveCommandOption(
kind: json['kind'] == 'flag' ? 'flag' : 'option',
name: name,
abbr: abbr is String && abbr.length == 1 ? abbr : null,
help: help is String ? help : null,
allowed: allowed is List ? allowed.map((v) => '$v').toList() : null,
defaultValue: json['defaultValue'],
);
}