pad.libre-service.eu-etherpad/src/node/utils/Cli.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-21 22:06:52 +01:00
'use strict';
/**
* The CLI module handles command line parameters
*/
/*
* 2012 Jordan Hollinger
*
* 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.
*/
// An object containing the parsed command-line options
exports.argv = {};
2020-11-23 19:24:19 +01:00
const argv = process.argv.slice(2);
let arg, prevArg;
// Loop through args
2020-11-23 19:24:19 +01:00
for (let i = 0; i < argv.length; i++) {
arg = argv[i];
// Override location of settings.json file
2021-01-21 22:06:52 +01:00
if (prevArg === '--settings' || prevArg === '-s') {
exports.argv.settings = arg;
}
2017-07-05 21:20:02 +02:00
// Override location of credentials.json file
2021-01-21 22:06:52 +01:00
if (prevArg === '--credentials') {
2017-07-05 21:20:02 +02:00
exports.argv.credentials = arg;
}
// Override location of settings.json file
2021-01-21 22:06:52 +01:00
if (prevArg === '--sessionkey') {
exports.argv.sessionkey = arg;
}
// Override location of settings.json file
2021-01-21 22:06:52 +01:00
if (prevArg === '--apikey') {
exports.argv.apikey = arg;
}
prevArg = arg;
}