Add documentation for LOUNGE_HOME environment variable in the CLI helper

This commit is contained in:
Jérémie Astori 2017-08-21 01:49:32 -04:00
parent 1e9910f899
commit 98bfe349d9
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
9 changed files with 35 additions and 1 deletions

View File

@ -4,10 +4,12 @@ var ClientManager = new require("../clientManager");
var colors = require("colors/safe");
var program = require("commander");
var Helper = require("../helper");
const Utils = require("./utils");
program
.command("add <name>")
.description("Add a new user")
.on("--help", Utils.extraHelp)
.action(function(name) {
var manager = new ClientManager();
var users = manager.getUsers();

View File

@ -4,10 +4,12 @@ var program = require("commander");
var child = require("child_process");
var colors = require("colors/safe");
var Helper = require("../helper");
const Utils = require("./utils");
program
.command("config")
.description(`Edit configuration file located at ${colors.green(Helper.CONFIG_PATH)}. Set the ${colors.green("LOUNGE_HOME")} environment variable to change.`)
.description(`Edit configuration file located at ${colors.green(Helper.CONFIG_PATH)}.`)
.on("--help", Utils.extraHelp)
.action(function() {
var child_spawn = child.spawn(
process.env.EDITOR || "vi",

View File

@ -5,10 +5,12 @@ var program = require("commander");
var child = require("child_process");
var colors = require("colors/safe");
var Helper = require("../helper");
const Utils = require("./utils");
program
.command("edit <name>")
.description(`Edit user file located at ${colors.green(Helper.getUserConfigPath("<name>"))}.`)
.on("--help", Utils.extraHelp)
.action(function(name) {
var users = new ClientManager().getUsers();
if (users.indexOf(name) === -1) {

View File

@ -8,9 +8,11 @@ var fs = require("fs");
var fsextra = require("fs-extra");
var path = require("path");
var Helper = require("../helper");
const Utils = require("./utils");
program.version(Helper.getVersion(), "-v, --version")
.option("--home <path>", `${colors.bold("[DEPRECATED]")} Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`)
.on("--help", Utils.extraHelp)
.parseOptions(process.argv);
if (program.home) {

View File

@ -3,10 +3,12 @@
var ClientManager = new require("../clientManager");
var program = require("commander");
var colors = require("colors/safe");
const Utils = require("./utils");
program
.command("list")
.description("List all users")
.on("--help", Utils.extraHelp)
.action(function() {
var users = new ClientManager().getUsers();
if (!users.length) {

View File

@ -3,10 +3,12 @@
var ClientManager = new require("../clientManager");
var program = require("commander");
var colors = require("colors/safe");
const Utils = require("./utils");
program
.command("remove <name>")
.description("Remove an existing user")
.on("--help", Utils.extraHelp)
.action(function(name) {
var manager = new ClientManager();
if (manager.removeUser(name)) {

View File

@ -5,10 +5,12 @@ var fs = require("fs");
var program = require("commander");
var colors = require("colors/safe");
var Helper = require("../helper");
const Utils = require("./utils");
program
.command("reset <name>")
.description("Reset user password")
.on("--help", Utils.extraHelp)
.action(function(name) {
var users = new ClientManager().getUsers();
if (users.indexOf(name) === -1) {

View File

@ -5,6 +5,7 @@ var program = require("commander");
var colors = require("colors/safe");
var server = require("../server");
var Helper = require("../helper");
const Utils = require("./utils");
program
.command("start")
@ -14,6 +15,7 @@ program
.option(" --public", "start in public mode")
.option(" --private", "start in private mode")
.description("Start the server")
.on("--help", Utils.extraHelp)
.action(function(options) {
var users = new ClientManager().getUsers();

18
src/command-line/utils.js Normal file
View File

@ -0,0 +1,18 @@
"use strict";
const colors = require("colors/safe");
class Utils {
static extraHelp() {
[
"",
"",
" Environment variable:",
"",
` LOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green("~/.lounge")}.`,
"",
].forEach((e) => console.log(e));
}
}
module.exports = Utils;