sshIdentityGenerator top-level property
Implementation
final sshIdentityGenerator = FigGenerator(
custom: (List<String> tokens, ExecuteCommandFunction? executeShellCommand,
FigGeneratorContext? context) async {
if (executeShellCommand == null) return [];
// tokens.slice(2).find(...)
// Assuming tokens include the command itself? Fig tokens usually start after command.
// TS: tokens.slice(2)
// Dart tokens are just arguments?
// The tokens passed to custom generator are usually the full line tokens or arguments.
// If tokens are ["ssh", "host", ...], then slice(2) makes sense.
// I'll assume standard tokenization.
final host = tokens
.skip(2)
.firstWhere((value) => !value.startsWith("-"), orElse: () => "");
if (host.isEmpty) {
return [];
}
final out = await executeShellCommand(ExecuteCommandInput(
command: "fig",
args: ["ssh", host, "--get-identities"],
));
final json = jsonDecode(out.stdout) as List;
return json
.map((h) => FigSuggestion(
name: h['displayName'],
))
.toList();
},
);