@drazenbebic/wdid 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +6 -2
  2. package/dist/index.js +110 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -28,10 +28,13 @@ This puts a `wdid` binary on your `PATH`.
28
28
  ## Usage
29
29
 
30
30
  ```sh
31
- wdid # all commits authored by you, across all branches
31
+ wdid # show help (no args = nothing to do)
32
32
  wdid today # commits from today
33
+ wdid yesterday # commits from yesterday
33
34
  wdid 2026-05-27 # commits from a specific day (YYYY-MM-DD)
35
+ wdid 2026-05 # commits from a specific month (YYYY-MM)
34
36
  wdid --from 2026-05-01 --to 2026-05-07 # a date range
37
+ wdid --all # all commits, no date filter
35
38
  wdid --author "Jane Doe" # someone else's commits
36
39
  wdid --repo ../api ../web # query multiple repos at once
37
40
  ```
@@ -75,7 +78,8 @@ With `--group-by-day`, the date moves into a section heading instead of repeatin
75
78
 
76
79
  | Option | Description |
77
80
  | -------------------------- | -------------------------------------------------------------------------------------------- |
78
- | `[date]` | A `YYYY-MM-DD` date or the literal `today`. Omit to show all history. |
81
+ | `[date]` | A `YYYY-MM-DD` date, a `YYYY-MM` month, or the literal `today` / `yesterday`. |
82
+ | `--all` | Show all history (no date filter). Required to opt into the unfiltered view explicitly. |
79
83
  | `--from <date>` | Start date (inclusive). |
80
84
  | `--to <date>` | End date (inclusive). |
81
85
  | `--author <name>` | Override the git author. Defaults to `git config user.name` (or `defaultAuthor` in config). |
package/dist/index.js CHANGED
@@ -973,12 +973,32 @@ var VALID_PRESETS = [
973
973
  function isIsoDate(value) {
974
974
  return /^\d{4}-\d{2}-\d{2}$/.test(value);
975
975
  }
976
+ function isYearMonth(value) {
977
+ return /^\d{4}-(0[1-9]|1[0-2])$/.test(value);
978
+ }
979
+ function resolveYearMonth(value) {
980
+ const year = Number.parseInt(value.slice(0, 4), 10);
981
+ const month = Number.parseInt(value.slice(5, 7), 10);
982
+ const lastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
983
+ const pad = (n) => String(n).padStart(2, "0");
984
+ return {
985
+ from: `${year}-${pad(month)}-01`,
986
+ to: `${year}-${pad(month)}-${pad(lastDay)}`
987
+ };
988
+ }
976
989
  function resolveDate(input) {
977
990
  if (input === "today") {
978
991
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
979
992
  }
993
+ if (input === "yesterday") {
994
+ const d = /* @__PURE__ */ new Date();
995
+ d.setUTCDate(d.getUTCDate() - 1);
996
+ return d.toISOString().slice(0, 10);
997
+ }
980
998
  if (!isIsoDate(input)) {
981
- throw new Error(`invalid date "${input}" \u2014 expected YYYY-MM-DD or "today"`);
999
+ throw new Error(
1000
+ `invalid date "${input}" \u2014 expected YYYY-MM-DD, "today", or "yesterday"`
1001
+ );
982
1002
  }
983
1003
  return input;
984
1004
  }
@@ -1007,9 +1027,15 @@ async function run(dateArg, options) {
1007
1027
  let from = options.from ? resolveDate(options.from) : void 0;
1008
1028
  let to = options.to ? resolveDate(options.to) : void 0;
1009
1029
  if (dateArg) {
1010
- const day = resolveDate(dateArg);
1011
- from = day;
1012
- to = day;
1030
+ if (isYearMonth(dateArg)) {
1031
+ const range = resolveYearMonth(dateArg);
1032
+ from = range.from;
1033
+ to = range.to;
1034
+ } else {
1035
+ const day = resolveDate(dateArg);
1036
+ from = day;
1037
+ to = day;
1038
+ }
1013
1039
  }
1014
1040
  const limit = parseLimit(options.limit);
1015
1041
  const perRepoEntries = await Promise.all(
@@ -1223,7 +1249,39 @@ async function runTogglSync(dateArg, options) {
1223
1249
  }
1224
1250
  var program = new Command();
1225
1251
  program.enablePositionalOptions();
1226
- program.name("wdid").description("What did I do? \u2014 summarize your git commits as a table").version("0.3.0", "-V, --version", "output the version number").argument("[date]", 'a YYYY-MM-DD date or "today"; omit to show all history').option("--from <date>", 'start date (YYYY-MM-DD or "today")').option("--to <date>", 'end date (YYYY-MM-DD or "today")').option(
1252
+ var isoArt = String.raw` ___ ___ ___
1253
+ /\__\ /\ \ ___ /\ \
1254
+ /:/ _/_ /::\ \ /\ \ /::\ \
1255
+ /:/ /\__\ /:/\:\ \ \:\ \ /:/\:\ \
1256
+ /:/ /:/ _/_ /:/ \:\__\ /::\__\ /:/ \:\__\
1257
+ /:/_/:/ /\__\ /:/__/ \:|__| __/:/\/__/ /:/__/ \:|__|
1258
+ \:\/:/ /:/ / \:\ \ /:/ / /\/:/ / \:\ \ /:/ /
1259
+ \::/_/:/ / \:\ /:/ / \::/__/ \:\ /:/ /
1260
+ \:\/:/ / \:\/:/ / \:\__\ \:\/:/ /
1261
+ \::/ / \::/__/ \/__/ \::/__/
1262
+ \/__/ ~~ ~~`;
1263
+ function gradientPaint(text, from, to) {
1264
+ const lines = text.split("\n");
1265
+ const maxY = Math.max(lines.length - 1, 1);
1266
+ const maxX = Math.max(1, ...lines.map((l) => l.length - 1));
1267
+ return lines.map(
1268
+ (line, y) => Array.from(line, (ch, x) => {
1269
+ if (ch === " ") {
1270
+ return ch;
1271
+ }
1272
+ const t = (y / maxY + x / maxX) / 2;
1273
+ const r = Math.round(from[0] + (to[0] - from[0]) * t);
1274
+ const g = Math.round(from[1] + (to[1] - from[1]) * t);
1275
+ const b = Math.round(from[2] + (to[2] - from[2]) * t);
1276
+ return chalk3.rgb(r, g, b)(ch);
1277
+ }).join("")
1278
+ ).join("\n");
1279
+ }
1280
+ var banner = gradientPaint(isoArt, [34, 211, 238], [217, 70, 239]) + " " + chalk3.rgb(217, 70, 239)(`v${"0.4.0"}`) + "\n";
1281
+ program.name("wdid").description("What did I do? \u2014 summarize your git commits as a table").version("0.4.0", "-V, --version", "output the version number").addHelpText("before", banner).argument(
1282
+ "[date]",
1283
+ 'a YYYY-MM-DD date, YYYY-MM month, "today", or "yesterday"'
1284
+ ).option("--all", "show all history (no date filter)").option("--from <date>", 'start date (YYYY-MM-DD, "today", or "yesterday")').option("--to <date>", 'end date (YYYY-MM-DD, "today", or "yesterday")').option(
1227
1285
  "--author <name>",
1228
1286
  "override the git author (defaults to git config user.name, then defaultAuthor in config)"
1229
1287
  ).option(
@@ -1256,7 +1314,20 @@ program.name("wdid").description("What did I do? \u2014 summarize your git commi
1256
1314
  process.exitCode = 1;
1257
1315
  }
1258
1316
  });
1259
- var togglCmd = program.command("toggl").description("Toggl integration commands");
1317
+ var togglCmd = program.command("toggl").description("Toggl integration commands").action(() => {
1318
+ togglCmd.help();
1319
+ });
1320
+ togglCmd.addHelpText(
1321
+ "after",
1322
+ `
1323
+ Examples:
1324
+ $ wdid toggl sync push today's commits
1325
+ $ wdid toggl sync yesterday push yesterday's commits
1326
+ $ wdid toggl sync 2026-05-27 push a specific day
1327
+ $ wdid toggl sync today --dry-run preview without pushing
1328
+ $ wdid toggl sync --workspace 12345 today override the workspace
1329
+ $ wdid toggl sync --from 2026-05-25 --to 2026-05-27 push a multi-day range`
1330
+ );
1260
1331
  togglCmd.command("sync [date]").description(
1261
1332
  "push the day's commits as Toggl time entries. Default: today. Pass --from/--to for a range."
1262
1333
  ).option("--dry-run", "preview the plan without pushing").option(
@@ -1313,7 +1384,23 @@ async function runConfigList(options) {
1313
1384
  function runConfigPath() {
1314
1385
  process.stdout.write(globalConfigPath() + "\n");
1315
1386
  }
1316
- var configCmd = program.command("config").description("Read and write the global wdid config file");
1387
+ var configCmd = program.command("config").description("Read and write the global wdid config file").action(() => {
1388
+ configCmd.help();
1389
+ });
1390
+ configCmd.addHelpText(
1391
+ "after",
1392
+ `
1393
+ Examples:
1394
+ $ wdid config keys list every available key
1395
+ $ wdid config set togglApiToken tok_abc123 set a scalar field
1396
+ $ wdid config set togglWorkspaceId 12345 numbers are parsed
1397
+ $ wdid config set togglOneEntryPerTicket false booleans take true/false
1398
+ $ wdid config set togglProjects.ABC- 67890 set a nested record entry
1399
+ $ wdid config get togglApiToken secrets are masked
1400
+ $ wdid config get togglApiToken --show-secrets reveal the secret
1401
+ $ wdid config list show all set fields
1402
+ $ wdid config path print the config file path`
1403
+ );
1317
1404
  configCmd.command("set <key> <value>").description(
1318
1405
  "Set a value in the global config (~/.config/wdid/config.json). Use dotted access for nested fields (togglProjects.ABC-)."
1319
1406
  ).action(async (key, value) => {
@@ -1355,4 +1442,20 @@ configCmd.command("path").description(
1355
1442
  configCmd.command("keys").description("List every config key with its type, default, and description.").action(() => {
1356
1443
  process.stdout.write(renderConfigKeys() + "\n");
1357
1444
  });
1445
+ program.addHelpText(
1446
+ "after",
1447
+ `
1448
+ Examples:
1449
+ $ wdid today commits from today
1450
+ $ wdid yesterday commits from yesterday
1451
+ $ wdid 2026-05-27 commits from a specific day
1452
+ $ wdid 2026-05 commits from a whole month
1453
+ $ wdid --from 2026-05-01 --to 2026-05-07 a date range
1454
+ $ wdid --all all history, no filter
1455
+ $ wdid toggl sync today push today's commits to Toggl
1456
+ $ wdid config list show global config`
1457
+ );
1458
+ if (process.argv.length <= 2) {
1459
+ program.help();
1460
+ }
1358
1461
  program.parseAsync(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drazenbebic/wdid",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "What did I do? — summarize your git activity per day as a tidy table, grouped by JIRA ticket.",
5
5
  "keywords": [
6
6
  "git",