This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

skills.hedgedoc: pad-edit.py usage on --help, refuse empty content

author
Hermes
committer
lassulus
date (Oct 18, 2026, 11:52 PM CEST) commit 84a68a42 parent 29be24b2
+15 -6
+1 -1
skills/hedgedoc/SKILL.md
··· 77 77 78 78 - `allowFreeURL = true` — pads can have custom slugs 79 79 - `defaultPermission = "freely"` — all pads are world-editable via URL 80 - - Edit replaces the entire pad content (full replacement, not partial edit) 80 + - Edit replaces the entire pad content (full replacement, not partial edit); empty content is refused 81 81 - Active browser sessions will see the change in real-time (pushed via socket.io) 82 82 - Pad IDs are from the URL: `https://pad.lassul.us/{PADID}` 83 83 - Edit uses UTF-16 code unit counting (JavaScript string length) for OT operations
+14 -5
skills/hedgedoc/pad-edit.py
··· 6 6 import urllib.request 7 7 import ssl 8 8 9 + USAGE = """Usage: pad-edit.py <pad-id> [file|-] 10 + Replace the pad's content with the file, or stdin when omitted or "-".""" 11 + 12 + # Before the bootstrap below, so --help needs no nix build or network. 13 + if len(sys.argv) < 2 or sys.argv[1].startswith("-"): 14 + help_asked = sys.argv[1:2] in (["-h"], ["--help"]) 15 + print(USAGE, file=sys.stdout if help_asked else sys.stderr) 16 + sys.exit(0 if help_asked else 1) 17 + 9 18 try: 10 19 import websocket 11 20 except ImportError: ··· 50 59 51 60 52 61 def main(): 53 - if len(sys.argv) < 2: 54 - print("Usage: pad-edit.py <pad-id> [file]", file=sys.stderr) 55 - print(" echo 'content' | pad-edit.py <pad-id>", file=sys.stderr) 56 - sys.exit(1) 57 - 58 62 pad_id = sys.argv[1] 59 63 60 64 # Read new content ··· 67 71 # Strip single trailing newline (added by shell heredoc/echo) 68 72 if new_content.endswith("\n"): 69 73 new_content = new_content[:-1] 74 + 75 + # An empty write would blank the pad. 76 + if not new_content: 77 + print("ERROR: Refusing to write empty content", file=sys.stderr) 78 + sys.exit(1) 70 79 71 80 # Step 1: Get session cookie 72 81 ctx = ssl.create_default_context()