Comparing version 1.4.0 to 1.5.0
@@ -29,8 +29,3 @@ #!/usr/bin/env node | ||
var type = argv.type; | ||
var pkey = strftime('time!%F %T', d); | ||
var tkey = 'time-type!' + type + '!' + strftime('%F %T', d); | ||
db.batch([ | ||
{ type: 'put', key: pkey, value: { type: type, message: message } }, | ||
{ type: 'put', key: tkey, value: 0 } | ||
], error); | ||
start(d, message, type, error); | ||
} | ||
@@ -44,3 +39,3 @@ else if (argv._[0] === 'stop') { | ||
if (err) error(err) | ||
else onrow({ key: key, value: value }) | ||
else onrowstop({ key: key, value: value }) | ||
}); | ||
@@ -52,5 +47,5 @@ } | ||
limit: 1, reverse: true | ||
}).once('data', onrow); | ||
}).once('data', onrowstop); | ||
} | ||
function onrow (row) { | ||
function onrowstop (row) { | ||
var m = argv.message; | ||
@@ -65,2 +60,21 @@ if (m) { | ||
} | ||
else if (argv._[0] === 'restart') { | ||
var k = argv.key || argv._[1]; | ||
if (k) { | ||
db.get(getKey(k), function (err, value) { | ||
if (err) error(err); | ||
else onrowrestart({ value: value }); | ||
}); | ||
} | ||
else { | ||
db.createReadStream({ | ||
gt: 'time!', lt: 'time!~', | ||
limit: 1, reverse: true | ||
}).once('data', onrowrestart); | ||
} | ||
function onrowrestart (row) { | ||
start(new Date, row.value.message, row.value.type, error); | ||
} | ||
} | ||
else if (argv._[0] === 'add' && argv._.length === 3) { | ||
@@ -272,2 +286,11 @@ var start = strftime('%F %T', new Date(argv._[1])); | ||
function start (date, message, type, cb) { | ||
var pkey = strftime('time!%F %T', d); | ||
var tkey = 'time-type!' + type + '!' + strftime('%F %T', d); | ||
db.batch([ | ||
{ type: 'put', key: pkey, value: { type: type, message: message } }, | ||
{ type: 'put', key: tkey, value: 0 } | ||
], cb); | ||
} | ||
function edit (src, cb) { | ||
@@ -274,0 +297,0 @@ var file = path.join(tmpdir, 'clocker-' + Math.random()); |
@@ -9,2 +9,5 @@ usage: | ||
clocker restart [STAMP] | ||
Restart either last clock or clock at STAMP. | ||
clocker status | ||
@@ -11,0 +14,0 @@ Show the elapsed time if the clock is active or "stopped". |
{ | ||
"name": "clocker", | ||
"version": "1.4.0", | ||
"version": "1.5.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
17923
5
367