Comparing version 1.13.2 to 1.14.0
@@ -249,12 +249,4 @@ #!/usr/bin/env node | ||
console.log( | ||
'%s %s [ %s - %s ] (%s)%s%s', | ||
toStamp(row.key), | ||
strftime('%F', start), | ||
strftime('%T', start), | ||
end ? strftime('%T', end) : 'NOW', | ||
fmt(elapsed), | ||
(row.value.type ? ' [' + row.value.type + ']' : ''), | ||
(row.value.archive ? ' A' : '') | ||
); | ||
printEntry(row.key, start, end, elapsed, row.value.type, row.value.archive); | ||
if (argv.verbose && row.value.message) { | ||
@@ -363,2 +355,43 @@ var lines = row.value.message.split('\n'); | ||
} | ||
else if (argv._[0] === 'report') { | ||
// options and arguments | ||
var day = argv.reportDay; | ||
// get report data | ||
var reportDay = (day && typeof day === 'string') ? getDate(day) : new Date(); | ||
var reportDayTomorrow = new Date(reportDay); | ||
reportDayTomorrow.setDate(reportDayTomorrow.getDate() +1); | ||
console.log('Report for %s:', printDate(reportDay)); | ||
var s = db.createReadStream({ | ||
gt: 'time!' + (strftime('%F', reportDay) || ''), | ||
lt: 'time!' + (strftime('%F', reportDayTomorrow) || '~') | ||
}); | ||
s.on('error', error); | ||
var sumsByType = {}; | ||
var totalSum = 0; | ||
s.pipe(through(function (row) { | ||
var start = new Date(row.key.split('!')[1]); | ||
var end = row.value.end && new Date(row.value.end); | ||
var elapsed = (end ? end : new Date) - start; | ||
printEntry(row.key, start, end, elapsed, row.value.type, row.value.archive); | ||
sumsByType[row.value.type] ? sumsByType[row.value.type] += elapsed : sumsByType[row.value.type] = elapsed; | ||
}, function end () { | ||
console.log(''); | ||
for(var type in sumsByType) { | ||
console.log("%s: %s", type, fmt(sumsByType[type])); | ||
totalSum += sumsByType[type]; | ||
} | ||
console.log("\ntotal: %s", fmt(totalSum)); | ||
})); | ||
} | ||
else usage(1) | ||
@@ -526,3 +559,26 @@ | ||
function printEntry (key, start, end, elapsed, type, archive) { | ||
console.log( | ||
'%s %s [ %s - %s ] (%s)%s%s', | ||
toStamp(key), | ||
strftime('%F', start), | ||
strftime('%T', start), | ||
end ? strftime('%T', end) : 'NOW', | ||
fmt(elapsed), | ||
(type ? ' [' + type + ']' : ''), | ||
(archive ? ' A' : '') | ||
); | ||
} | ||
function printDate(date) { | ||
var monthNames = [ | ||
"January", "February", "March", | ||
"April", "May", "June", "July", | ||
"August", "September", "October", | ||
"November", "December" | ||
]; | ||
return date.getDate() + ' ' + monthNames[date.getMonth()] + ' ' + date.getFullYear(); | ||
} | ||
function addData (obj) { | ||
@@ -529,0 +585,0 @@ var data = minimist(argv['--']); |
@@ -27,2 +27,6 @@ usage: | ||
clocker report {--reportDay DATE} | ||
Show all logged hours of a specific day. | ||
If no --reportDay is set, the current day will be used. | ||
clocker csv {--gt DATE, --lt DATE, --props FIELDS, -a} | ||
@@ -29,0 +33,0 @@ Generate CSV output. |
{ | ||
"name": "clocker", | ||
"version": "1.13.2", | ||
"version": "1.14.0", | ||
"description": "track project hours", | ||
@@ -18,7 +18,4 @@ "bin": { | ||
}, | ||
"devDependencies": { | ||
"tape": "~2.3.2" | ||
}, | ||
"scripts": { | ||
"test": "tape test/*.js" | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
@@ -25,0 +22,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
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
25273
0
532
164
1