better stuff

This commit is contained in:
Nishi 2026-05-08 19:07:45 +09:00
commit c89f96ce8a
Signed by: nishi
GPG key ID: 27EF69B208EB9343
5 changed files with 41 additions and 12 deletions

View file

@ -1,19 +1,34 @@
if(ARGV.length == 1) {
console.log("Type '" + ARGV[0] + " --help' for help");
process.exit(1);
}
const PADDING = 16;
var action;
for(var i = 1; i < ARGV.length; i++) {
if(ARGV[i] == "--help") {
var keys;
console.log("PMake " + pmake.VERSION + " - Pyrite's build script generator");
console.log("");
console.log("Usage: " + ARGV[0] + " [options] action [arguments]");
console.log("");
console.log("ACTIONS");
keys = Object.keys(pmake.actions);
for(var i = 0; i < keys.length; i++) {
console.log(" " + keys[i] + " ".repeat(PADDING - keys[i].length) + pmake.actions[keys[i]].description);
}
process.exit(0);
} else if(ARGV[i].startsWith("--")) {
console.log("Error: invalid option '" + ARGV[i].substr(2) + "'");
process.exit(1);
} else if(pmake.actions[ARGV[i]]) {
action = ARGV[i];
break;
} else {
console.log("Error: no such action '" + ARGV[i] + "'");
process.exit(1);
}
}
if(!action) {
console.log("Type '" + ARGV[0] + " --help' for help");
process.exit(1);
}