forked from stanford-oval/genie-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·79 lines (68 loc) · 2.67 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env node
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of Almond
//
// Copyright 2016-2020 The Board of Trustees of the Leland Stanford Junior University
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Giovanni Campagna <[email protected]>
"use strict";
// load thingpedia to initialize the polyfill
require('thingpedia');
// common initialization code
process.on('unhandledRejection', (up) => { throw up; });
require('./util/config_init');
const i18n = require('./util/i18n');
const localfs = require('./util/local_fs');
const Config = require('./config');
i18n.init(Config.SUPPORTED_LANGUAGES);
localfs.init();
const argparse = require('argparse');
const commands = {
// administrative commands
'bootstrap': require('./scripts/bootstrap'),
'execute-sql-file': require('./scripts/execute-sql-file'),
'migrate-dataset': require('./scripts/migrate-dataset'),
// daemons
'run-almond': require('./almond/master'),
'run-frontend': require('./frontend'),
'run-nlp': require('./nlp/main'),
'run-training': require('./training/daemon'),
// batch jobs
'apply-credits': require('./scripts/apply-credits'),
'run-training-task': require('./training/run-training-task'),
// utility commands
'get-config': require('./scripts/get-config'),
'get-user-shards': require('./scripts/get-user-shards'),
'generate-cheatsheet': require('./scripts/generate-cheatsheet'),
'sync-discourse-sso': require('./scripts/sync-discourse-sso'),
'download-dataset': require('./scripts/download-dataset'),
'download-log': require('./scripts/download-log'),
'upload-dataset': require('./scripts/upload-dataset'),
'compile-exact-btrie': require('./scripts/compile-exact-btrie'),
};
const parser = new argparse.ArgumentParser({
add_help: true,
description: "The Almond Virtual Assistant - Cloud Edition"
});
const subparsers = parser.add_subparsers({
title: 'Available sub-commands',
dest: 'subcommand',
required: true
});
for (let subcommand in commands)
commands[subcommand].initArgparse(subparsers);
const args = parser.parse_args();
commands[args.subcommand].main(args);