toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() => {
      'name': name,
      if (displayName != null) 'displayName': displayName,
      if (description != null) 'description': description,
      if (subcommands != null)
        'subcommands': subcommands!.map((e) => e.toJson()).toList(),
      if (options != null)
        'options': options!.map((e) => e.toJson()).toList(),
      if (args != null && args!.isNotEmpty)
        'args': args!.map((e) => e.toJson()).toList(),
      if (icon != null) 'icon': icon,
      if (loadSpec != null &&
          (loadSpec is String ||
              loadSpec is FigSubcommand ||
              loadSpec is Map))
        'loadSpec': loadSpec is FigSubcommand ? loadSpec.toJson() : loadSpec,
      if (filterStrategy != null) 'filterStrategy': filterStrategy!.name,
      if (priority != null) 'priority': priority,
      if (requiresSubcommand == true) 'requiresSubcommand': true,
      if (additionalSuggestions != null)
        'additionalSuggestions': additionalSuggestions!
            .map((e) => e is FigSuggestion ? e.toJson() : e)
            .toList(),
      if (generateSpecCacheKey != null && generateSpecCacheKey is String)
        'generateSpecCacheKey': generateSpecCacheKey,
      if (parserDirectives != null && parserDirectives is Map)
        'parserDirectives': parserDirectives,
      if (cache != null) 'cache': cache,
      if (insertValue != null) 'insertValue': insertValue,
      if (replaceValue != null) 'replaceValue': replaceValue,
      if (isDangerous == true) 'isDangerous': true,
      if (deprecated != null) 'deprecated': deprecated,
      if (hidden) 'hidden': true,
    };