Skip to content

Commit 6da6780

Browse files
authored
Merge pull request #8 from shenald-dev/refactor/cli-argument-handling-17471977207799949078
🧹 Refactor CLI argument handling to eliminate code duplication
2 parents ee03fc6 + 9ed5d3f commit 6da6780

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,22 @@ async function main() {
119119
}
120120

121121
if (require.main === module) {
122-
// If no args, run benchmark
123-
if (process.argv.includes('--benchmark')) {
124-
main().then(r => { console.log('Results:', r); process.exit(0); }).catch(e => { console.error(e); process.exit(1); });
125-
} else if (process.argv.includes('--server')) {
122+
if (process.argv.includes('--server')) {
126123
const PORT = process.env.PORT || 3000;
127124
app.listen(PORT, () => {
128125
console.log(`One API Gateway listening on port ${PORT}`);
129126
});
130127
} else {
131-
// Original behavior default: run benchmark
132-
main().then(r => { console.log('Results:', r); process.exit(0); }).catch(e => { console.error(e); process.exit(1); });
128+
// Default to benchmark if no --server flag
129+
main()
130+
.then(r => {
131+
console.log('Results:', r);
132+
process.exit(0);
133+
})
134+
.catch(e => {
135+
console.error(e);
136+
process.exit(1);
137+
});
133138
}
134139
}
135140

0 commit comments

Comments
 (0)