spaps
Version:
Sweet Potato Authentication & Payment Service CLI - Docker Compose orchestrator for local Python/FastAPI SPAPS server with built-in admin middleware
61 lines (45 loc) • 1.36 kB
JavaScript
/**
* SPAPS CLI - Sweet Potato Authentication & Payment Service
*/
const chalk = require('chalk');
const { buildProgram } = require('../src/cli-dispatcher');
const { createHandlers } = require('../src/handlers');
const version = require('../package.json').version;
// ASCII Art Logo
const logo = `
${chalk.yellow('🍠 SPAPS')} - Sweet Potato Authentication & Payment Service
`;
const handlers = createHandlers(version, logo);
const program = buildProgram({ handlers, dryRun: false, version, logo });
const argv = process.argv.slice(2);
function shouldRouteToHome(args) {
if (!args.length) {
return true;
}
const flagsWithValues = new Set(['-p', '--port', '--server-url']);
const bareFlags = new Set(['--json']);
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (arg === '--help' || arg === '-h' || arg === '--version' || arg === '-V') {
return false;
}
if (bareFlags.has(arg)) {
continue;
}
if (arg.startsWith('--port=') || arg.startsWith('--server-url=')) {
continue;
}
if (flagsWithValues.has(arg)) {
index += 1;
continue;
}
return false;
}
return true;
}
if (shouldRouteToHome(argv)) {
program.parse([process.argv[0], process.argv[1], 'home', ...argv]);
} else {
program.parse(process.argv);
}