Comparing version 1.18.0 to 1.19.0
@@ -81,5 +81,6 @@ #!/usr/bin/env node | ||
.option('--lt <date>', 'show dates upto') | ||
.option('--week [value]', 'show given week') | ||
.option('--month [value]', 'show given month') | ||
.option('--year [value]', 'show given year') | ||
.option('--day [value]', 'show given day (default: today)') | ||
.option('--week [value]', 'show given week (default: current week)') | ||
.option('--month [value]', 'show given month (default: current month)') | ||
.option('--year [value]', 'show given year (default: current year)') | ||
.option('-r, --rate <value>', 'add rate property', parseFloat) | ||
@@ -98,6 +99,8 @@ .option('-a, --all', 'include archived dates') | ||
.option('--lt <date>', 'show dates upto') | ||
.option('--week [value]', 'show given week') | ||
.option('--month [value]', 'show given month') | ||
.option('--year [value]', 'show given year') | ||
.option('--day [value]', 'show given day (default: today)') | ||
.option('--week [value]', 'show given week (default: current week)') | ||
.option('--month [value]', 'show given month (default: current month)') | ||
.option('--year [value]', 'show given year (default: current year)') | ||
.option('-a, --all', 'include archived dates') | ||
.option('-r, --report', 'show report of all logged data entries') | ||
.action(list) | ||
@@ -120,5 +123,6 @@ | ||
.option('--lt <date>', 'show dates upto') | ||
.option('--week [value]', 'show given week') | ||
.option('--month [value]', 'show given month') | ||
.option('--year [value]', 'show given year') | ||
.option('--day [value]', 'show given day (default: today)') | ||
.option('--week [value]', 'show given week (default: current week)') | ||
.option('--month [value]', 'show given month (default: current month)') | ||
.option('--year [value]', 'show given year (default: current year)') | ||
.option('-a, --all', 'include archived dates') | ||
@@ -171,5 +175,6 @@ .option('--props <fields>', 'additionally displayed fields', cmdlist) | ||
.option('--lt <date>', 'archive dates upto') | ||
.option('--week [value]', 'show given week') | ||
.option('--month [value]', 'show given month') | ||
.option('--year [value]', 'show given year') | ||
.option('--day [value]', 'show given day (default: today)') | ||
.option('--week [value]', 'show given week (default: current week)') | ||
.option('--month [value]', 'show given month (default: current month)') | ||
.option('--year [value]', 'show given year (default: current year)') | ||
.action(archive) | ||
@@ -182,5 +187,6 @@ | ||
.option('--lt <date>', 'unarchive dates upto') | ||
.option('--week [value]', 'show given week') | ||
.option('--month [value]', 'show given month') | ||
.option('--year [value]', 'show given year') | ||
.option('--day [value]', 'show given day (default: today)') | ||
.option('--week [value]', 'show given week (default: current week)') | ||
.option('--month [value]', 'show given month (default: current month)') | ||
.option('--year [value]', 'show given year (default: current year)') | ||
.action(unarchive) | ||
@@ -277,27 +283,10 @@ | ||
clocker.dataStream(filter).on('error', function (err) { | ||
ifError(err) | ||
}).on('end', function () { | ||
success() | ||
}).on('data', function (entry) { | ||
printEntry(entry) | ||
if (cmd.verbose) { | ||
printMessage(entry.data.message) | ||
if (cmd.report) { | ||
if (filter.lt && filter.gt && filter.lt.getTime() - filter.gt.getTime() === 24 * 60 * 60 * 1000) { | ||
console.log('Report for %s:', printDate(filter.gt)) | ||
} else { | ||
console.log('Report for %s – %s:', printDate(filter.gt, 'open start'), printDate(filter.lt, 'open end')) | ||
} | ||
}) | ||
} | ||
} | ||
function report (cmd) { | ||
clocker = initialize(cmd) | ||
const filter = getFilter(cmd) | ||
let reportDay = (cmd.reportDay && typeof cmd.reportDay === 'string') ? cmd.reportDay : 'today' | ||
reportDay = getDate(reportDay) | ||
const reportDayTomorrow = new Date(reportDay.getTime() + (24 * 60 * 60 * 1000)) | ||
filter.gt = reportDay | ||
filter.lt = reportDayTomorrow | ||
console.log('Report for %s:', printDate(reportDay)) | ||
const sumsByType = {} | ||
@@ -308,8 +297,10 @@ let totalSum = 0 | ||
}).on('end', function () { | ||
console.log('') | ||
for (const stype in sumsByType) { | ||
console.log('%s: %s', stype, Clocker.formatElapsed(sumsByType[stype])) | ||
totalSum += sumsByType[stype] | ||
if (cmd.report) { | ||
console.log('') | ||
for (const stype in sumsByType) { | ||
console.log('%s: %s', stype, Clocker.formatElapsed(sumsByType[stype])) | ||
totalSum += sumsByType[stype] | ||
} | ||
console.log('\ntotal: %s', Clocker.formatElapsed(totalSum)) | ||
} | ||
console.log('\ntotal: %s', Clocker.formatElapsed(totalSum)) | ||
@@ -332,2 +323,9 @@ success() | ||
function report (cmd) { | ||
cmd.day = cmd.reportDay ?? true | ||
cmd.report = true | ||
return list(cmd) | ||
} | ||
function csv (cmd) { | ||
@@ -594,2 +592,10 @@ clocker = initialize(cmd) | ||
} | ||
if (cmd.day) { | ||
let date = (cmd.day && typeof cmd.day === 'string') ? cmd.day : 'today' | ||
date = getDate(date) | ||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate()) | ||
const tomorrow = new Date(date.getTime() + (24 * 60 * 60 * 1000)) | ||
filter.gt = date | ||
filter.lt = tomorrow | ||
} | ||
if (cmd.week) { | ||
@@ -701,3 +707,7 @@ let date = (cmd.week && typeof cmd.week === 'string') ? cmd.week : 'today' | ||
function printDate (date) { | ||
function printDate (date, defaultStr = 'n/a') { | ||
if (typeof date === 'undefined') { | ||
return defaultStr | ||
} | ||
if (typeof date === 'string') { | ||
@@ -704,0 +714,0 @@ date = getDate(date) |
{ | ||
"name": "clocker", | ||
"version": "1.18.0", | ||
"version": "1.19.0", | ||
"description": "track project hours", | ||
@@ -5,0 +5,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123474
2174