Standardize CLI args
This commit is contained in:
parent
522192f025
commit
54f178d910
|
@ -11,8 +11,8 @@ const chalk = require("chalk");
|
|||
|
||||
let argv = yargs.argv;
|
||||
let [ configurationPath, task, item ] = argv._;
|
||||
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
|
||||
|
||||
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
|
||||
let configuration = require(absoluteConfigurationPath);
|
||||
|
||||
return Promise.try(() => {
|
||||
|
|
8
bin/run
8
bin/run
|
@ -14,8 +14,10 @@ const createKernel = require("../src/kernel");
|
|||
|
||||
let argv = yargs.argv;
|
||||
let configurationPath = argv._[0];
|
||||
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
|
||||
let listenHost = argv.listenHost ?? "127.0.0.1";
|
||||
let listenPort = argv.listenPort ?? 3131;
|
||||
|
||||
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
|
||||
let configuration = require(absoluteConfigurationPath);
|
||||
|
||||
return Promise.try(() => {
|
||||
|
@ -34,5 +36,7 @@ return Promise.try(() => {
|
|||
});
|
||||
});
|
||||
|
||||
metricsApp.listen(3131);
|
||||
metricsApp.listen({ host: listenHost, port: listenPort }, () => {
|
||||
console.log(`Metrics server listening on port ${listenPort}, host ${listenHost}`);
|
||||
});
|
||||
});
|
||||
|
|
12
bin/server
12
bin/server
|
@ -21,6 +21,7 @@ const express = require("express");
|
|||
const expressPromiseRouter = require("express-promise-router");
|
||||
const assert = require("assert");
|
||||
const path = require("path");
|
||||
const yargs = require("yargs");
|
||||
|
||||
const pipe = require("@promistream/pipe");
|
||||
const fromNodeStream = require("@promistream/from-node-stream");
|
||||
|
@ -33,9 +34,10 @@ const isString = require("@validatem/is-string");
|
|||
const initialize = require("../src/initialize");
|
||||
const errors = require("../src/errors");
|
||||
|
||||
assert(process.argv.length >= 4);
|
||||
let configurationPath = process.argv[2];
|
||||
let listenHost = process.argv[3];
|
||||
let argv = yargs.argv;
|
||||
let configurationPath = argv._[0];
|
||||
let listenHost = argv.listenHost ?? "127.0.0.1";
|
||||
let listenPort = argv.listenPort ?? 3000;
|
||||
|
||||
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
|
||||
let configuration = require(absoluteConfigurationPath);
|
||||
|
@ -133,7 +135,7 @@ return Promise.try(() => {
|
|||
});
|
||||
|
||||
app.use(router);
|
||||
app.listen({ host: listenHost, port: 3000 }, () => {
|
||||
console.log("Server listening on port 3000");
|
||||
app.listen({ host: listenHost, port: listenPort }, () => {
|
||||
console.log(`API server listening on port ${listenPort}, host ${listenHost}`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,8 +11,8 @@ const chalk = require("chalk");
|
|||
|
||||
let argv = yargs.argv;
|
||||
let [ configurationPath, task, item ] = argv._;
|
||||
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
|
||||
|
||||
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
|
||||
let configuration = require(absoluteConfigurationPath);
|
||||
|
||||
return Promise.try(() => {
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
"pg-query-stream": "^4.1.0",
|
||||
"prom-client": "^14.0.1",
|
||||
"syncpipe": "^1.0.0",
|
||||
"yargs": "^16.2.0"
|
||||
"yargs": "^17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@joepie91/eslint-config": "^1.1.0",
|
||||
|
|
20
yarn.lock
20
yarn.lock
|
@ -3080,20 +3080,20 @@ yallist@^4.0.0:
|
|||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
|
||||
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
|
||||
|
||||
yargs-parser@^20.2.2:
|
||||
version "20.2.9"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
|
||||
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
|
||||
yargs-parser@^21.0.0:
|
||||
version "21.0.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35"
|
||||
integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==
|
||||
|
||||
yargs@^16.2.0:
|
||||
version "16.2.0"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
|
||||
integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
|
||||
yargs@^17.3.1:
|
||||
version "17.3.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.3.1.tgz#da56b28f32e2fd45aefb402ed9c26f42be4c07b9"
|
||||
integrity sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==
|
||||
dependencies:
|
||||
cliui "^7.0.2"
|
||||
escalade "^3.1.1"
|
||||
get-caller-file "^2.0.5"
|
||||
require-directory "^2.1.1"
|
||||
string-width "^4.2.0"
|
||||
string-width "^4.2.3"
|
||||
y18n "^5.0.5"
|
||||
yargs-parser "^20.2.2"
|
||||
yargs-parser "^21.0.0"
|
||||
|
|
Loading…
Reference in a new issue