2024-02-08 11:10:46 +01:00
|
|
|
async function main(args_raw : Array<string>) : Promise<void>
|
2024-02-07 15:14:30 +01:00
|
|
|
{
|
2024-02-08 11:10:46 +01:00
|
|
|
// args
|
|
|
|
|
const arg_handler : lib_plankton.args.class_handler = new lib_plankton.args.class_handler(
|
2024-02-07 15:14:30 +01:00
|
|
|
{
|
2024-02-08 11:10:46 +01:00
|
|
|
"input": lib_plankton.args.class_argument.positional({
|
|
|
|
|
"index": 0,
|
|
|
|
|
"type": lib_plankton.args.enum_type.string,
|
|
|
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
|
|
|
|
"default": null,
|
|
|
|
|
"info": "path to input file",
|
|
|
|
|
"name": "input",
|
|
|
|
|
}),
|
|
|
|
|
"output": lib_plankton.args.class_argument.volatile({
|
|
|
|
|
"indicators_long": ["output"],
|
|
|
|
|
"indicators_short": ["o"],
|
|
|
|
|
"type": lib_plankton.args.enum_type.string,
|
|
|
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
|
|
|
|
"default": "html",
|
|
|
|
|
"info": "output format",
|
|
|
|
|
"name": "output",
|
|
|
|
|
}),
|
|
|
|
|
"help": lib_plankton.args.class_argument.volatile({
|
|
|
|
|
"indicators_long": ["help"],
|
|
|
|
|
"indicators_short": ["h"],
|
|
|
|
|
"type": lib_plankton.args.enum_type.boolean,
|
|
|
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
|
|
|
|
"default": false,
|
|
|
|
|
"info": "show help",
|
|
|
|
|
"name": "help",
|
|
|
|
|
}),
|
2024-02-07 15:14:30 +01:00
|
|
|
}
|
|
|
|
|
);
|
2024-02-08 11:10:46 +01:00
|
|
|
const args : Record<string, any> = arg_handler.read(lib_plankton.args.enum_environment.cli, args_raw.join(" "));
|
|
|
|
|
// process.stdout.write(JSON.stringify(args)); return;
|
|
|
|
|
|
|
|
|
|
// exec
|
|
|
|
|
if (args.help)
|
|
|
|
|
{
|
|
|
|
|
process.stdout.write(
|
|
|
|
|
arg_handler.generate_help(
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const element_raw : string = lib_plankton.json.decode(await lib_plankton.file.read(args.input))
|
|
|
|
|
let element : type_element = element_make(element_raw);
|
|
|
|
|
|
|
|
|
|
const output : type_output<string> = output_make<string>({"kind": args.output, "data": {}});
|
|
|
|
|
|
|
|
|
|
const result : string = output.render_element(element);
|
|
|
|
|
process.stdout.write(result + "\n");
|
|
|
|
|
}
|
2024-02-07 15:14:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-02-08 11:10:46 +01:00
|
|
|
main(process.argv.slice(2))
|
|
|
|
|
.then(() => {})
|
|
|
|
|
.catch((reason) => {process.stderr.write(String(reason));})
|
|
|
|
|
;
|
2024-02-07 15:14:30 +01:00
|
|
|
|