harvest-overtime
Version:
Track the overtime!
27 lines (26 loc) • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const decorator_1 = require("./cli/decorator");
const presenter_1 = require("./cli/presenter");
const reporter_1 = require("./reporter");
const options = commander_1.program.opts();
commander_1.program
.version(reporter_1.CUR_VERSION)
.option("-i, --input [input]", `Path and name of the incoming CSV file. If not provided, will be '${reporter_1.DEF_INPUT}'`)
.option("-o, --output [output]", `Path and name of the resulting CSV file. If not provided, will be '${reporter_1.DEF_OUTPUT}'`)
.option("-h, --dayhours [hours]", `Regular working day hours. If not provided, will be '${reporter_1.DEF_REGULAR_DAY_HOURS}' hours`)
.option("-p, --print", "Print report to the standard output. If not set, it won't print the report")
.parse(process.argv);
const args = decorator_1.decorateArgs({ default: reporter_1.DEF_INPUT, option: options.input }, { default: reporter_1.DEF_OUTPUT, option: options.output }, { default: reporter_1.DEF_REGULAR_DAY_HOURS, option: options.dayhours });
reporter_1.default(args.inputPath, args.outputPath, args.regularDayHours)
.then((report) => {
console.log(presenter_1.toInfo(args));
if (options.print) {
console.log(presenter_1.toTable(report));
}
})
.catch((error) => {
console.error(presenter_1.toError(args, error));
});