convert method

  1. @override
String convert()
override

Implementation

@override
String convert() {
  final root = _root;
  final rootName = root.name;
  final lines = <String>[_filterFunction()];
  final rootFlags = _flagsFor(root);
  final rootOptions = _optionsFor(root);

  _writeInputTables(
    lines,
    root,
    [rootName],
    flags: rootFlags,
    options: rootOptions,
    global: true,
  );
  final commands = root.commands;
  _writeRoutingTables(lines, root, [rootName]);
  if (commands != null) {
    for (final command in commands) {
      _writeCommand(lines, command, [rootName], rootFlags, rootOptions);
    }
  }
  _writeRootHandler(lines, root, [rootName], rootOptions);
  _writeDispatcher(lines, rootName);
  lines.add('complete -F _${_identifier(rootName)}_completion $rootName');
  return '${lines.join('\n')}\n';
}