@hasna/events 0.1.6 → 0.1.7

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 (2) hide show
  1. package/dist/cli/index.js +20 -2
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -564,10 +564,19 @@ function parseGlobalArgs(argv) {
564
564
  return { json, dir, rest };
565
565
  }
566
566
  function takeOption(args, name) {
567
+ const equalsPrefix = `${name}=`;
568
+ const equalsIndex = args.findIndex((arg) => arg.startsWith(equalsPrefix));
569
+ if (equalsIndex !== -1) {
570
+ const value2 = args[equalsIndex]?.slice(equalsPrefix.length);
571
+ args.splice(equalsIndex, 1);
572
+ return value2;
573
+ }
567
574
  const index = args.indexOf(name);
568
575
  if (index === -1)
569
576
  return;
570
577
  const value = args[index + 1];
578
+ if (value === undefined)
579
+ throw new Error(`${name} requires a value`);
571
580
  args.splice(index, 2);
572
581
  return value;
573
582
  }
@@ -580,7 +589,7 @@ function takeFlag(args, name) {
580
589
  }
581
590
  function takeMany(args, name) {
582
591
  const values = [];
583
- while (args.includes(name)) {
592
+ while (args.includes(name) || args.some((arg) => arg.startsWith(`${name}=`))) {
584
593
  const value = takeOption(args, name);
585
594
  if (value !== undefined)
586
595
  values.push(value);
@@ -710,6 +719,10 @@ async function runEventsCli(argv = process.argv.slice(2), options = {}) {
710
719
  printWebhooksHelp(options);
711
720
  return;
712
721
  }
722
+ if (tail.includes("--help") || tail.includes("-h")) {
723
+ printWebhooksHelp(options);
724
+ return;
725
+ }
713
726
  await handleWebhooks(client, command, tail, parsed, options);
714
727
  return;
715
728
  }
@@ -718,6 +731,10 @@ async function runEventsCli(argv = process.argv.slice(2), options = {}) {
718
731
  printEventsHelp(options);
719
732
  return;
720
733
  }
734
+ if (tail.includes("--help") || tail.includes("-h")) {
735
+ printEventsHelp(options);
736
+ return;
737
+ }
721
738
  await handleEvents(client, command, tail, parsed, options);
722
739
  return;
723
740
  }
@@ -735,6 +752,7 @@ async function handleWebhooks(client, command, tail, parsed, options) {
735
752
  const retryBackoffMs = numberOption(takeOption(args, "--retry-backoff-ms"));
736
753
  const disabled = takeFlag(args, "--disabled");
737
754
  const headerValues = takeMany(args, "--header");
755
+ const commandArgs = takeMany(args, "--arg");
738
756
  const redactions = takeMany(args, "--redact");
739
757
  const filters = parseFilter(args);
740
758
  const target = args[0];
@@ -755,7 +773,7 @@ async function handleWebhooks(client, command, tail, parsed, options) {
755
773
  if (transport === "webhook") {
756
774
  channel.webhook = { url: target, secret, headers: parseHeaders(headerValues), timeoutMs };
757
775
  } else if (transport === "command") {
758
- channel.command = { command: target, args: args.slice(1), timeoutMs };
776
+ channel.command = { command: target, args: [...args.slice(1), ...commandArgs], timeoutMs };
759
777
  } else {
760
778
  throw new Error(`Transport ${transport} is reserved for future use and cannot be added yet`);
761
779
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/events",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Shared event envelopes, local subscriptions, and webhook delivery for Hasna open-source apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",