| 12345678910111213141516171819202122232425262728293031323334353637 |
- #!/usr/bin/env node
- 'use strict';
- const {join} = require('path');
- const {cliBasics} = require('command-line-basics');
- const {
- getDate, getTodayJSON
- } = require('../api/controllers/bDateController.js');
- const optionDefinitions = cliBasics(
- join(__dirname, './optionDefinitions.js')
- );
- if (!optionDefinitions) { // cliBasics handled
- process.exit(); // eslint-disable-line no-process-exit
- }
- const {date, verbose} = optionDefinitions;
- let dateObj;
- if (date) {
- const dte = new Date(date);
- dateObj = getDate({
- year: dte.getFullYear(),
- month: dte.getMonth(),
- day: dte.getDate(),
- hour: dte.getHours(),
- minute: dte.getMinutes(),
- second: dte.getSeconds()
- });
- } else {
- dateObj = getTodayJSON();
- }
- const output = verbose ? dateObj : dateObj.json.message;
- // eslint-disable-next-line no-console
- console.log(output);
|