add fish completion script generator
ADD
completion
+mple

MODIFY
packages/@romejs/cli-flags/Parser.ts
packages/@romejs/cli-flags/Parser.ts
@@ -612,17 +612,47 @@ export default class Parser<T> {
// this.commands contains command information
// reporter.logAllNoMarkup to output to stdout
- reporter;
+
+ // console.log("flags: ", flags);
+ // console.log("declaredFlags: ", this.declaredFlags);
+ // console.log("commands: ", this.commands);
switch (shell) {
case 'bash':
- // TODO
+ reporter.logAllNoMarkup(this.genBashCompletions());
+ case 'fish': {
+ reporter.logAllNoMarkup(this.genFishCompletions());
break;
+ }
+ }
+ }
- case 'fish':
- // TODO
- break;
+ genFishCompletions() {
+ let script = '';
+ const scriptPre = 'complete -c rome';
+
+ // add rome
+ script += `${scriptPre} -f\n`;
+
+ // add command completions
+ for (let [subcmd, meta] of this.commands.entries()) {
+ script += `${scriptPre} -n '__fish_use_subcommand' -a '${subcmd}' -d '${meta.description}'\n`;
}
+
+ // add flag completions
+ for (let [, meta] of this.declaredFlags.entries()) {
+ const subcmdCond =
+ meta.command === undefined
+ ? ''
+ : `-n '__fish_seen_subcommand_from ${meta.command}'`;
+ script += `${scriptPre} ${subcmdCond} -l '${meta.name}'\n`;
+ }
+
+ return script;
+ }
+
+ genBashCompletions() {
+ return 'TODO';
}
async showHelp(command: undefined | AnyCommandOptions = this.ranCommand) {

ADD
result
+complete -c rome -f
+complete -c rome -n '__fish_use_subcommand' -a 'init' -d 'create a project config'
+complete -c rome -n '__fish_use_subcommand' -a 'start' -d 'start daemon (if none running)'
+complete -c rome -n '__fish_use_subcommand' -a 'develop' -d 'TODO'
+complete -c rome -n '__fish_use_subcommand' -a 'stop' -d 'stop a running daemon if one exists'
+complete -c rome -n '__fish_use_subcommand' -a 'run' -d 'TODO'
+complete -c rome -n '__fish_use_subcommand' -a 'restart' -d 'restart daemon'
+complete -c rome -n '__fish_use_subcommand' -a 'status' -d 'get the current daemon status'
+complete -c rome -n '__fish_use_subcommand' -a 'lsp' -d 'connect to an lsp'
+complete -c rome -n '__fish_use_subcommand' -a 'test' -d 'run tests'
+complete -c rome -n '__fish_use_subcommand' -a 'lint' -d 'run lint against a set of files'
+complete -c rome -n '__fish_use_subcommand' -a 'config' -d 'Modify a project config'
+complete -c rome -n '__fish_use_subcommand' -a 'bundle' -d 'build a standalone js bundle for a package'
+complete -c rome -n '__fish_use_subcommand' -a 'parse' -d 'parse a single file and dump its ast'
+complete -c rome -n '__fish_use_subcommand' -a 'analyzeDependencies' -d 'analyze and dump the dependencies of a file'
+complete -c rome -n '__fish_use_subcommand' -a 'resolve' -d 'resolve a file'
+complete -c rome -n '__fish_use_subcommand' -a 'compile' -d 'compile a single file'
+complete -c rome -n '__fish_use_subcommand' -a 'publish' -d 'TODO'
+complete -c rome -n '__fish_use_subcommand' -a 'ci' -d 'run lint and tests'
+complete -c rome -n '__fish_use_subcommand' -a 'format' -d 'TODO'
+complete -c rome -n '__fish_use_subcommand' -a '_evict' -d 'evict a file from the memory cache'
+complete -c rome -n '__fish_use_subcommand' -a '_moduleSignature' -d 'get the module type signature of a file'
+complete -c rome -n '__fish_use_subcommand' -a '_noop' -d 'TODO'
+complete -c rome -n '__fish_use_subcommand' -a 'rage' -d 'TODO'
+complete -c rome -n '__fish_use_subcommand' -a 'logs' -d 'TODO'
+complete -c rome -l 'version'
+complete -c rome -l 'generateAutocomplete'
+complete -c rome -n '__fish_seen_subcommand_from init' -l 'defaults'
+complete -c rome -n '__fish_seen_subcommand_from test' -l 'coverage'
+complete -c rome -n '__fish_seen_subcommand_from test' -l 'showAllCoverage'
+complete -c rome -n '__fish_seen_subcommand_from test' -l 'updateSnapshots'
+complete -c rome -n '__fish_seen_subcommand_from test' -l 'freezeSnapshots'
+complete -c rome -n '__fish_seen_subcommand_from test' -l 'focusAllowed'
+complete -c rome -n '__fish_seen_subcommand_from test' -l 'syncTests'
+complete -c rome -n '__fish_seen_subcommand_from lint' -l 'save'
+complete -c rome -n '__fish_seen_subcommand_from lint' -l 'formatOnly'
+complete -c rome -n '__fish_seen_subcommand_from lint' -l 'changed'
+complete -c rome -n '__fish_seen_subcommand_from bundle' -l 'quiet'
+complete -c rome -n '__fish_seen_subcommand_from parse' -l 'allowDiagnostics'
+complete -c rome -n '__fish_seen_subcommand_from parse' -l 'compact'
+complete -c rome -n '__fish_seen_subcommand_from parse' -l 'sourceType'
+complete -c rome -n '__fish_seen_subcommand_from analyzeDependencies' -l 'compact'
+complete -c rome -n '__fish_seen_subcommand_from analyzeDependencies' -l 'focusSource'
+complete -c rome -n '__fish_seen_subcommand_from compile' -l 'bundle'
+complete -c rome -n '__fish_seen_subcommand_from ci' -l 'fix'
+complete -c rome -n '__fish_seen_subcommand_from format' -l 'allowDiagnostics'
+

add fish completion script generator