easyppk
Version:
simple CLI tool ppk processing
89 lines (54 loc) • 1.93 kB
JavaScript
var pkg = require('../package.json')
var readline = require('colors')
const { Command } = require('commander')
const program = new Command()
// var shell = require('shelljs')
var easyppk = require('./app')
var _results = []
// var utils = require('./utils')
start() // start the program
function start () {
// Setup initial parameters
program
.version(pkg.version, '-v, --version', 'output the current version')
.command('process', 'process PPK files inside folder')
.option('-p, --path [folderPath]', 'folder path to all PPK files', './')
.command('status', 'show status of all processes in the queue')
.command('remove [ID]', 'remove proccess from the queue')
.command('list', 'list all succcessful processes')
.usage("easyppk [options] [command]")
.on('--help', function() {
console.log('')
console.log('Examples:')
console.log('')
console.log(' $ easyppk process -p ./Document/my-files')
console.log(' $ easyppk list')
console.log('')
}, {isDefault: true})
program.parse(process.argv);
// Start
// if (program.path) {
// if (program.path === true) return console.log('missing file path')
// return process_files(program.path)
// }
}
// Do the processing
function process_files (pathString) {
easyppk.initialize(pathString, onProcessEnd)
}
// Once processing ends, check errors and status
function onProcessEnd (err, results, status_code) {
// This is imnportant to keep here, we have to resume the terminal
process.stdin.resume()
// If the processing returned with errors let's show them to the user
if (err) return console.log(err)
/////////////////////////////
// SUCCESS
if (status_code.equals('SUCCESS')) {
console.log("please use ", "easyppk -c".yellow, " to check on progress")
// Exit proces
process.exit()
}
_results = results
}