pusharmor 0.0.52__tar.gz → 0.0.53__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pusharmor
3
- Version: 0.0.52
3
+ Version: 0.0.53
4
4
  Summary: PushArmor command-line client
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://pusharmor.com
@@ -41,7 +41,7 @@ distribution:
41
41
  - `pusharmor pair` - list your devices; `pusharmor pair ID` pairs with one: compare the
42
42
  fingerprint on both devices, then confirm or reject.
43
43
  - `pusharmor devices` - list your devices and their pairing status (as `pusharmor pair` does).
44
- - `pusharmor send TEXT` - send a URL or text to all paired devices; `--to ID` for one,
44
+ - `pusharmor send TEXT` - send a URL or text to all paired devices; `-d ID` for one,
45
45
  `--text` to send a URL as plain text. With `-` or piped input it reads stdin.
46
46
  - `pusharmor listen` - print messages as they arrive; `--json`, `--tsv`, or
47
47
  `--exec PROG` (runs PROG ID NAME PLATFORM TYPE BODY per message). `--json` escapes
@@ -31,7 +31,7 @@ distribution:
31
31
  - `pusharmor pair` - list your devices; `pusharmor pair ID` pairs with one: compare the
32
32
  fingerprint on both devices, then confirm or reject.
33
33
  - `pusharmor devices` - list your devices and their pairing status (as `pusharmor pair` does).
34
- - `pusharmor send TEXT` - send a URL or text to all paired devices; `--to ID` for one,
34
+ - `pusharmor send TEXT` - send a URL or text to all paired devices; `-d ID` for one,
35
35
  `--text` to send a URL as plain text. With `-` or piped input it reads stdin.
36
36
  - `pusharmor listen` - print messages as they arrive; `--json`, `--tsv`, or
37
37
  `--exec PROG` (runs PROG ID NAME PLATFORM TYPE BODY per message). `--json` escapes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pusharmor
3
- Version: 0.0.52
3
+ Version: 0.0.53
4
4
  Summary: PushArmor command-line client
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://pusharmor.com
@@ -41,7 +41,7 @@ distribution:
41
41
  - `pusharmor pair` - list your devices; `pusharmor pair ID` pairs with one: compare the
42
42
  fingerprint on both devices, then confirm or reject.
43
43
  - `pusharmor devices` - list your devices and their pairing status (as `pusharmor pair` does).
44
- - `pusharmor send TEXT` - send a URL or text to all paired devices; `--to ID` for one,
44
+ - `pusharmor send TEXT` - send a URL or text to all paired devices; `-d ID` for one,
45
45
  `--text` to send a URL as plain text. With `-` or piped input it reads stdin.
46
46
  - `pusharmor listen` - print messages as they arrive; `--json`, `--tsv`, or
47
47
  `--exec PROG` (runs PROG ID NAME PLATFORM TYPE BODY per message). `--json` escapes
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python3
2
- # PushArmor command-line client, version 0.0.52
2
+ # PushArmor command-line client, version 0.0.53
3
3
  """PushArmor command-line client.
4
4
 
5
5
  The top part is the core layer: encodings, keys, signed requests, HPKE,
@@ -42,7 +42,7 @@ except BaseException: # missing, or broken: no _cffi_backend is ImportError, a
42
42
  sys.stderr.write("error: " + CRYPTO_MISSING + "\n")
43
43
  sys.exit(1)
44
44
 
45
- VERSION = "0.0.52"
45
+ VERSION = "0.0.53"
46
46
  USER_AGENT = "PushArmor-CLI/" + VERSION
47
47
 
48
48
  # ---- encodings ----
@@ -3111,9 +3111,9 @@ COMMANDS = {
3111
3111
  [(("--json",), {"action": "store_true", "help": "one JSON object per line"}),
3112
3112
  (("--tsv",), {"action": "store_true", "help": "tab-separated lines"}),
3113
3113
  (("--exec",), {"metavar": "PROG", "help": "run PROG ID NAME PLATFORM TYPE BODY per message"})]),
3114
- "send": (cmd_send, "Send a URL or text to your paired devices (all, or --to ID).",
3114
+ "send": (cmd_send, "Send a URL or text to your paired devices (all, or -d ID).",
3115
3115
  [(("message",), {"nargs": "*", "metavar": "MESSAGE", "help": "text to send; - or none reads stdin"}),
3116
- (("--to",), {"action": "append", "metavar": "ID", "help": "send to this device only (repeatable)"}),
3116
+ (("-d", "--to"), {"dest": "to", "action": "append", "metavar": "ID", "help": "send to this device only (repeatable)"}),
3117
3117
  (("--text",), {"action": "store_true", "help": "send as plain text, not as a URL or phone number"})]),
3118
3118
  "rename": (cmd_rename, "Change the name your other devices show for this device.",
3119
3119
  [(("name",), {"metavar": "NAME", "help": "1 to 32 plain ASCII characters, no double quote"})]),
@@ -3214,6 +3214,9 @@ def _main(argv):
3214
3214
  f.reconfigure(encoding="utf-8", newline="\n")
3215
3215
  set_action("")
3216
3216
  parser = build_parser()
3217
+ if not (sys.argv[1:] if argv is None else argv): # no arguments: the full help, as a usage error
3218
+ parser.print_help(sys.stderr)
3219
+ return EXIT_USAGE
3217
3220
  args = parser.parse_args(argv)
3218
3221
  if not getattr(args, "_check", lambda a: True)(args):
3219
3222
  parser.error("Use only one of --json, --tsv, and --exec.")
@@ -106,7 +106,7 @@ def test_command_table_is_frozen():
106
106
  assert list(pa.COMMANDS) == ["login", "logout", "pair", "devices", "listen", "send", "rename", "delete"]
107
107
 
108
108
 
109
- @pytest.mark.parametrize("argv", [[], ["frob"], ["rename"], ["delete"], ["send", "--bogus"], ["pair", "a", "b"],
109
+ @pytest.mark.parametrize("argv", [["frob"], ["rename"], ["delete"], ["send", "--bogus"], ["pair", "a", "b"],
110
110
  ["listen", "--json", "--tsv"], ["listen", "--tsv", "--exec", "x"], ["login", "x"]])
111
111
  def test_bad_usage_exits_2(argv, capsys):
112
112
  with pytest.raises(SystemExit) as e:
@@ -123,9 +123,15 @@ def test_help_for_every_command(name, capsys):
123
123
  assert e.value.code == 0 and "usage: pusharmor " + name in capsys.readouterr().out
124
124
 
125
125
 
126
+ def test_send_help_shows_d_and_to(capsys):
127
+ with pytest.raises(SystemExit):
128
+ pa.main(["send", "--help"])
129
+ assert re.search(r"-d( ID)?, --to ID", capsys.readouterr().out) # Python 3.13 writes the metavar once
130
+
131
+
126
132
  def test_parse_args_per_command():
127
133
  p = pa.build_parser()
128
- a = p.parse_args(["--config", "/x", "send", "--to", "abcdef", "--to", "123456", "--text", "hi", "there"])
134
+ a = p.parse_args(["--config", "/x", "send", "-d", "abcdef", "--to", "123456", "--text", "hi", "there"])
129
135
  assert (a.config, a.command, a.to, a.text, a.message) == ("/x", "send", ["abcdef", "123456"], True, ["hi", "there"])
130
136
  assert p.parse_args(["pair"]).id is None and p.parse_args(["pair", "abcdef"]).id == "abcdef"
131
137
  a = p.parse_args(["listen", "--exec", "notify"])
@@ -512,7 +518,7 @@ def test_pair_send_listen(net, tmp_path, monkeypatch, capsys):
512
518
  assert run(a, "send", "https://example.com/a b") == 0
513
519
  del net.hooks[("POST", "send")]
514
520
  monkeypatch.setattr(sys, "stdin", Stdin(tty=False, data="line one\n\tline two\n".encode()))
515
- assert run(a, "send", "--to", pa.id_hex(idb)[:6]) == 0
521
+ assert run(a, "send", "-d", pa.id_hex(idb)[:6]) == 0
516
522
  monkeypatch.setattr(sys, "stdin", Stdin())
517
523
 
518
524
  net.stop.set()
@@ -1383,6 +1389,18 @@ def test_help_lists_every_exit_code(capsys):
1383
1389
  assert " %-3d %s" % (code, text) in out
1384
1390
 
1385
1391
 
1392
+ def test_no_arguments_prints_the_full_help_on_stderr(capsys, monkeypatch):
1393
+ with pytest.raises(SystemExit):
1394
+ pa.main(["--help"])
1395
+ help_text = capsys.readouterr().out
1396
+ assert pa.main([]) == 2
1397
+ out, err = capsys.readouterr()
1398
+ assert out == "" and err == help_text
1399
+ monkeypatch.setattr(sys, "argv", ["pusharmor"])
1400
+ assert pa.main() == 2
1401
+ assert capsys.readouterr().err == help_text
1402
+
1403
+
1386
1404
  # ---- crashes: every error is one line on stderr and a listed exit code ----
1387
1405
 
1388
1406
  class BrokenOut:
File without changes
File without changes