disableForCommandsGenerator top-level property

FigGenerator disableForCommandsGenerator
final

Implementation

final disableForCommandsGenerator = FigGenerator(
  script: ["fig", "settings", "autocomplete.disableForCommands"],
  postProcess: (String out, [List<String>? tokens]) {
    final existing = out.split("\n").where((item) => item.isNotEmpty).toList();

    final append = FigSuggestion(
      name: "Disable new CLI...",
      description:
          "You must pass a valid JSON array of CLI tools contained within single quotes. e.g. '[\"npm\",\"cd\",\"ls\"]'",
      icon: "fig://icon?type=box",
      insertValue: jsonEncode(existing + ["{cursor}"]),
    );

    final enabledAll = FigSuggestion(
      name: "Enable all commands",
      icon: "fig://icon?type=box",
      insertValue: "'[]'",
    );

    return [
      append,
      enabledAll,
      ...existing.map((disabledCommand) {
        return FigSuggestion(
          name: "Enable $disabledCommand",
          icon: "fig://icon?type=box",
          insertValue: jsonEncode(
            existing.where((cmd) => cmd != disabledCommand).toList(),
          ),
        );
      }),
    ];
  },
);