Skip to content

Commit 3354664

Browse files
committed
feat: --short-version flag
1 parent d532b55 commit 3354664

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/main.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,27 @@ import { DelayCommand } from './scenario/DelayCommand.js';
1616
import { ExpectPinCommand } from './scenario/ExpectPinCommand.js';
1717
import { SetControlCommand } from './scenario/SetControlCommand.js';
1818
import { WaitSerialCommand } from './scenario/WaitSerialCommand.js';
19-
import { uploadFirmware } from './uploadFirmware.js';
2019
import { WriteSerialCommand } from './scenario/WriteSerialCommand.js';
20+
import { uploadFirmware } from './uploadFirmware.js';
2121

2222
const millis = 1_000_000;
2323

24+
function printVersion(short = false) {
25+
const { sha, version } = readVersion();
26+
if (short) {
27+
console.log(`${version} (${sha})`);
28+
} else {
29+
console.log(`Wokwi CLI v${version} (${sha})`);
30+
}
31+
}
32+
2433
async function main() {
2534
const args = arg(
2635
{
2736
'--help': Boolean,
2837
'--quiet': Boolean,
2938
'--version': Boolean,
39+
'--short-version': Boolean,
3040
'--diagram-file': String,
3141
'--elf': String,
3242
'--expect-text': String,
@@ -60,12 +70,13 @@ async function main() {
6070
const timeoutExitCode = args['--timeout-exit-code'] ?? 42;
6171
const timeoutNanos = timeout * millis;
6272

73+
if (args['--version'] === true || args['--short-version'] === true) {
74+
printVersion(args['--short-version']);
75+
process.exit(0);
76+
}
77+
6378
if (!quiet) {
64-
const { sha, version } = readVersion();
65-
console.log(`Wokwi CLI v${version} (${sha})`);
66-
if (args['--version']) {
67-
process.exit(0);
68-
}
79+
printVersion();
6980
}
7081

7182
if (args['--help']) {

0 commit comments

Comments
 (0)