Comparing version 1.15.3 to 1.15.4
@@ -72,3 +72,4 @@ #!/usr/bin/env node | ||
.option('-d, --datadir <path>') | ||
.option('-t, --type <value>', 'filter by type, a string or /regex/') | ||
.option('--filter <key=value>', 'filter by key, value as string or /regex/', collect, []) | ||
.option('-t, --type <value>', 'short for --filter "type=<value>"') | ||
.option('--gt <date>', 'show dates from gt on') | ||
@@ -85,3 +86,4 @@ .option('--lt <date>', 'show dates upto') | ||
.option('-v, --verbose', 'also show clocked messages') | ||
.option('-t, --type <value>', 'filter by type, a string or /regex/') | ||
.option('--filter <key=value>', 'filter by key, value as string or /regex/', collect, []) | ||
.option('-t, --type <value>', 'short for --filter "type=<value>"') | ||
.option('--gt <date>', 'show dates from gt on') | ||
@@ -105,3 +107,4 @@ .option('--lt <date>', 'show dates upto') | ||
.option('-d, --datadir <path>') | ||
.option('-t, --type <value>', 'filter by type, a string or /regex/') | ||
.option('--filter <key=value>', 'filter by key, value as string or /regex/', collect, []) | ||
.option('-t, --type <value>', 'short for --filter "type=<value>"') | ||
.option('--gt <date>', 'show dates from gt on') | ||
@@ -514,13 +517,18 @@ .option('--lt <date>', 'show dates upto') | ||
var filter = {} | ||
filter.test = (e) => true | ||
cmd.filter = cmd.filter || [] | ||
if (cmd.type) { | ||
if (cmd.type[0] === '/' && cmd.type.slice(-1)[0] === '/') { | ||
// regex | ||
filter.test = (e) => RegExp(cmd.type.slice(1, -1)).test(e.data.type) | ||
cmd.filter.push('type=' + cmd.type) | ||
} | ||
cmd.filter.forEach((cmdFilter) => { | ||
var kv = cmdFilter.split('=') | ||
if (isRegex(kv[1])) { | ||
extendFilter(filter, (e) => RegExp(kv[1].slice(1, -1)).test(e.data[kv[0]])) | ||
} else { | ||
// string | ||
filter.test = (e) => e.data.type === cmd.type | ||
// ignore eslint rule "eqeqeq" to allow type-converting comparison | ||
extendFilter(filter, (e) => e.data[kv[0]] == kv[1]) // eslint-disable-line eqeqeq | ||
} | ||
} | ||
}) | ||
@@ -534,14 +542,5 @@ if (cmd.gt) { | ||
var oldTest = filter.test | ||
if (!cmd.all) { | ||
// filter archived records | ||
filter.test = (e) => { | ||
if (!oldTest(e)) { | ||
return false | ||
} | ||
if (e.data && e.data.archive) { | ||
return false | ||
} | ||
return true | ||
} | ||
extendFilter(filter, (e) => !(e.data && e.data.archive)) | ||
} | ||
@@ -552,2 +551,12 @@ | ||
function extendFilter (filter, func) { | ||
if (!filter.test) { | ||
filter.test = func | ||
return | ||
} | ||
var oldTest = filter.test | ||
filter.test = (e) => (oldTest(e) && func(e)) | ||
} | ||
function dir (cmd) { | ||
@@ -670,4 +679,13 @@ if (cmd.datadir) { | ||
function isRegex (str) { | ||
return (str[0] === '/' && str.slice(-1)[0] === '/') | ||
} | ||
function cmdlist (val) { | ||
return val.split(',') | ||
} | ||
function collect (val, memo) { | ||
memo.push(val) | ||
return memo | ||
} |
{ | ||
"name": "clocker", | ||
"version": "1.15.3", | ||
"version": "1.15.4", | ||
"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
116022
1973