Fix yargs --version implementation printing "unknown" for built .exe's

This commit is contained in:
Dillon DuPont
2025-11-18 09:03:22 -05:00
parent 5fa73fb0b1
commit fb55b42920
3 changed files with 59 additions and 2 deletions

View File

@@ -22,6 +22,27 @@ export async function runCli() {
'\n' +
'Documentation: https://docs.cua.ai/libraries/cua-cli/commands'
);
// version command
argv = argv.command(
'version',
'Show CUA CLI version',
(y) => y,
async () => {
try {
const home = process.env.HOME || process.env.USERPROFILE || '';
const path = `${home}/.cua/bin/.version`;
const version = await Bun.file(path).text();
const v = version.trim();
if (v) {
console.log(v);
} else {
console.log('unknown');
}
} catch {
console.log('unknown');
}
}
);
argv = registerAuthCommands(argv);
argv = registerSandboxCommands(argv);
await argv.demandCommand(1).strict().help().parseAsync();