#!/usr/bin/env node
const yargs = require('yargs'); // Minimalistic command-line argument parser
const { hideBin } = require('yargs'); // Hide default yargs options
const argv = yargs(hideBin(process.argv)) // Set up yargs with command-line arguments
.option('mode', {
alias: 'm',
describe: 'Development mode (true/false)',
type: 'boolean',
default: true, // Default to development mode
})
.option('logLevel', {
alias: 'l',
describe: 'Log level (e.g., debug, info, warn, error)',
type: 'string',
default: 'info',
})
.option('apiUrl', {
alias: 'a',
describe: 'API URL to use',
type: 'string',
default: 'http://localhost:3000',
})
.option('port', {
alias: 'p',
describe: 'Port to listen on',
type: 'number',
default: 3000,
})
.help() // Add help command
.alias('help', 'h') // Alias for help command
.argv; // Parse command-line arguments
// Access the options
const { mode, logLevel, apiUrl, port } = argv;
// Example usage: Log the settings
console.log('Development Mode:', mode);
console.log('Log Level:', logLevel);
console.log('API URL:', apiUrl);
console.log('Port:', port);
//Further logic can be added here to use the options.
Add your comment