Skip to content

Commit

Permalink
fix(cli): don't eat up first -* arg
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 3, 2023
1 parent acf06a0 commit 77b483b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const subCommands = {
};

async function main() {
let subCommand = process.argv[2];

const args = process.argv.slice(2);
let subCommand = args[0];
if (!subCommand || subCommand.startsWith("-")) {
subCommand = "_default";
} else {
args.shift();
}

if (!(subCommand in subCommands)) {
consola.error(`Unknown command ${subCommand}`);
process.exit(1);
}

await subCommands[subCommand]().then((r) =>
r.default(mri(process.argv.splice(3)))
);
await subCommands[subCommand]().then((r) => r.default(mri(args)));
}

main().catch(consola.error);

0 comments on commit 77b483b

Please sign in to comment.