Skip to content

Commit

Permalink
chore: remove workaround of yargs/yargs#2268 and yargs/yargs#2270
Browse files Browse the repository at this point in the history
  • Loading branch information
tasshi-me committed Mar 17, 2023
1 parent 3a65455 commit bec7f47
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions src/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,11 @@ import yargs from "yargs";
import { recordCommand } from "./record";
import packageJson from "../../package.json";

const customCompletion = (
current: string,
argv: yargs.Argv,
completionFilter: (onCompleted?: CompletionCallback) => any,
done: (completions: string[]) => any
) => {
completionFilter((err, defaultCompletions) => {
if (!defaultCompletions) {
done([]);
return;
}

const filteredCompletions: string[] = [];
const aliasPattern = /^--?[a-zA-Z\d]:$/;
defaultCompletions.forEach((completion) => {
// TODO: remove this workaround after https://github.com/yargs/yargs/issues/2268 is fixed.
if (aliasPattern.test(completion)) {
return;
}

// TODO: remove this workaround after https://github.com/yargs/yargs/issues/2270 is fixed.
filteredCompletions.push(completion.replace(/(\r\n|\n|\r)/gm, " "));
});
done(filteredCompletions);
});
};

// eslint-disable-next-line no-unused-expressions
yargs
.command(recordCommand)
.demandCommand()
.strict()
.version(packageJson.version)
.help()
.completion("completion", customCompletion as any).argv;
.completion().argv;

0 comments on commit bec7f47

Please sign in to comment.