238 lines
6.6 KiB
TypeScript
238 lines
6.6 KiB
TypeScript
|
|
async function main(
|
||
|
|
) : Promise<void>
|
||
|
|
{
|
||
|
|
// consts
|
||
|
|
const version : string = "0.8";
|
||
|
|
|
||
|
|
// init
|
||
|
|
await lib_plankton.translate.initialize_promise(
|
||
|
|
{
|
||
|
|
"verbosity": 1,
|
||
|
|
"order": ["de", "en"],
|
||
|
|
"packages": await Promise.all(
|
||
|
|
[
|
||
|
|
{"identifier": "de", "path": "localization/de.json"},
|
||
|
|
{"identifier": "en", "path": "localization/en.json"},
|
||
|
|
]
|
||
|
|
.map(
|
||
|
|
(entry) => (
|
||
|
|
lib_plankton.file.read(entry.path)
|
||
|
|
.then(content => Promise.resolve(JSON.parse(content)))
|
||
|
|
.then(tree => Promise.resolve({"meta": {"identifier": entry.identifier}, "tree": tree}))
|
||
|
|
)
|
||
|
|
)
|
||
|
|
),
|
||
|
|
}
|
||
|
|
);
|
||
|
|
|
||
|
|
// args
|
||
|
|
const arg_handler : lib_plankton.args.class_handler = new lib_plankton.args.class_handler(
|
||
|
|
{
|
||
|
|
"order_path": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "order_path",
|
||
|
|
"type": lib_plankton.args.enum_type.string,
|
||
|
|
"kind": lib_plankton.args.enum_kind.positional,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": "monitoring.hmdl.json",
|
||
|
|
"parameters": {
|
||
|
|
"index": 0,
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.order_path"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"show_help": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "help",
|
||
|
|
"type": lib_plankton.args.enum_type.boolean,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["help"],
|
||
|
|
"indicators_short": ["h"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.show_help"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"show_version": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "version",
|
||
|
|
"type": lib_plankton.args.enum_type.boolean,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["version"],
|
||
|
|
"indicators_short": ["v"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.show_version"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"show_schema": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "schema",
|
||
|
|
"type": lib_plankton.args.enum_type.boolean,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["schema"],
|
||
|
|
"indicators_short": ["s"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.show_schema"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"expose_full_order": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "expose_full_order",
|
||
|
|
"type": lib_plankton.args.enum_type.boolean,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["expose-full-order"],
|
||
|
|
"indicators_short": ["e"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.expose_full_order"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"erase_state": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "erase_state",
|
||
|
|
"type": lib_plankton.args.enum_type.boolean,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["erase-state"],
|
||
|
|
"indicators_short": ["x"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.erase_state"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"database_path": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "database_path",
|
||
|
|
"type": lib_plankton.args.enum_type.string,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["database-path"],
|
||
|
|
"indicators_short": ["d"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.database_path"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"mutex_path": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "mutex_path",
|
||
|
|
"type": lib_plankton.args.enum_type.string,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["mutex-path"],
|
||
|
|
"indicators_short": ["m"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.mutex_path"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"send_ok_notifications": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "send_ok_notifications",
|
||
|
|
"type": lib_plankton.args.enum_type.boolean,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["send-ok-notifications"],
|
||
|
|
"indicators_short": ["y"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.send_ok_notifications"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"language": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "language",
|
||
|
|
"type": lib_plankton.args.enum_type.string,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": false,
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["language"],
|
||
|
|
"indicators_short": ["l"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.language"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
"time_to_live": new lib_plankton.args.class_argument(
|
||
|
|
{
|
||
|
|
"name": "time_to_live",
|
||
|
|
"type": lib_plankton.args.enum_type.float,
|
||
|
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||
|
|
"mode": lib_plankton.args.enum_mode.replace,
|
||
|
|
"default": (60 * 60 * 24 * 7),
|
||
|
|
"parameters": {
|
||
|
|
"indicators_long": ["time-to-live"],
|
||
|
|
"indicators_short": ["t"],
|
||
|
|
},
|
||
|
|
"info": lib_plankton.translate.get("help.args.time_to_live"),
|
||
|
|
}
|
||
|
|
),
|
||
|
|
}
|
||
|
|
);
|
||
|
|
const args : Record<string, any> = arg_handler.read(
|
||
|
|
lib_plankton.args.enum_environment.cli,
|
||
|
|
process.argv.slice(2).join(" ")
|
||
|
|
);
|
||
|
|
|
||
|
|
// exec
|
||
|
|
if (args.show_help) {
|
||
|
|
process.stdout.write(
|
||
|
|
arg_handler.generate_help(
|
||
|
|
{
|
||
|
|
"programname": "heimdall",
|
||
|
|
"description": lib_plankton.translate.get("help.title"),
|
||
|
|
"executable": "heimdall",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
if (args.show_version) {
|
||
|
|
process.stdout.write(version + "\n");
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
if (args.show_version) {
|
||
|
|
process.stdout.write(version + "\n");
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
const check_kind_implementations : Record<string, _heimdall.checks.type_check> = {
|
||
|
|
};
|
||
|
|
const channel_kind_implementations : Record<string, _heimdall.channels.type_channel> = {
|
||
|
|
};
|
||
|
|
if (args.show_schema) {
|
||
|
|
process.stdout.write(
|
||
|
|
lib_plankton.json.encode(
|
||
|
|
_heimdall.order.schema_root(
|
||
|
|
check_kind_implementations,
|
||
|
|
channel_kind_implementations
|
||
|
|
),
|
||
|
|
true
|
||
|
|
)
|
||
|
|
+
|
||
|
|
"\n"
|
||
|
|
)
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
process.stdout.write(JSON.stringify(args, undefined, "\t") + "\n");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
main();
|