@bobfrankston/mailx 1.0.26 → 1.0.28

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/bin/mailx.js +21 -6
  2. package/package.json +1 -1
package/bin/mailx.js CHANGED
@@ -17,14 +17,29 @@ import net from "node:net";
17
17
 
18
18
  const PORT = 9333;
19
19
  const args = process.argv.slice(2);
20
- const serverMode = args.includes("--server");
21
- const noBrowser = args.includes("--no-browser");
22
- const verbose = args.includes("--verbose");
20
+
21
+ // Normalize: accept both -flag and --flag
22
+ function hasFlag(name) { return args.includes(`-${name}`) || args.includes(`--${name}`); }
23
+
24
+ const serverMode = hasFlag("server");
25
+ const noBrowser = hasFlag("no-browser");
26
+ const verbose = hasFlag("verbose");
27
+
28
+ // Validate arguments
29
+ const knownFlags = ["server", "no-browser", "verbose", "external", "kill", "v", "version"];
30
+ for (const arg of args) {
31
+ const flag = arg.replace(/^--?/, "");
32
+ if (arg.startsWith("-") && !knownFlags.includes(flag)) {
33
+ console.error(`Unknown option: ${arg}`);
34
+ console.error("Usage: mailx [-server] [-verbose] [-kill] [-v] [-no-browser] [-external]");
35
+ process.exit(1);
36
+ }
37
+ }
23
38
 
24
39
  function log(...msg) { if (verbose) console.log("[mailx]", ...msg); }
25
40
 
26
41
  // Kill any running mailx server
27
- if (args.includes("--kill") || args.includes("-kill")) {
42
+ if (hasFlag("kill")) {
28
43
  log("Killing mailx processes...");
29
44
  const { execSync } = await import("node:child_process");
30
45
  // Kill by port
@@ -46,7 +61,7 @@ if (args.includes("--kill") || args.includes("-kill")) {
46
61
  }
47
62
 
48
63
  // Version
49
- if (args.includes("-v") || args.includes("--version") || args.includes("-version")) {
64
+ if (hasFlag("v") || hasFlag("version")) {
50
65
  const pkgPath = path.join(import.meta.dirname, "..", "package.json");
51
66
  try {
52
67
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
@@ -89,7 +104,7 @@ async function main() {
89
104
 
90
105
  console.log("Starting mailx server...");
91
106
  log(`Loading server from: ${path.join(import.meta.dirname, "..", "packages", "mailx-server", "index.js")}`);
92
- if (args.includes("--external")) process.argv.push("--external");
107
+ if (hasFlag("external")) process.argv.push("--external");
93
108
  await import("../packages/mailx-server/index.js");
94
109
 
95
110
  if (!noBrowser) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",