skysync-cli
Version:
SkySync Command Line Interface
82 lines (81 loc) • 2.61 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = void 0;
const fs = require("fs");
const process = require("process");
const yargs = require("yargs");
const Liftoff = require('liftoff');
const mypackage = require('../package');
process.env.INIT_CWD = process.cwd();
const cli = new Liftoff({
name: mypackage.name,
configName: mypackage.name,
extensions: {
'.json': null
},
v8flags: require('v8flags')
});
function run() {
cli.prepare({}, function (env) {
cli.execute(env, function (env) {
const configPath = env.configPath;
if (configPath) {
yargs.config(JSON.parse(fs.readFileSync(configPath, 'utf-8')));
}
return yargs
.env('SKYSYNC')
.config()
.version(mypackage.version)
.help()
.usage('Usage: ' + cli.name + ' [command]')
.options({
'output-json': {
alias: 'json',
desc: 'Output results as JSON',
type: 'boolean',
global: true,
group: 'Advanced'
},
'server': {
desc: 'The SkySync server URI',
type: 'string',
global: true,
group: 'Connection'
},
'username': {
alias: 'user',
desc: 'The username',
default: 'admin',
type: 'string',
global: true,
group: 'Connection'
},
'password': {
type: 'string',
desc: 'The password',
global: true,
group: 'Connection'
},
'site': {
type: 'string',
desc: 'The remote site context',
global: true,
group: 'Connection'
}
})
.commandDir('./commands')
.group([
'config',
'help',
'version',
], 'Advanced')
.global([
'Advanced',
'Connection'
])
.demandCommand(1, 'You must provide a command')
.argv;
});
});
}
exports.run = run;