{"id":51026444,"url":"https://github.com/just-be-dev/webview-cli","last_synced_at":"2026-06-21T20:01:41.500Z","repository":{"id":362607015,"uuid":"1259902731","full_name":"just-be-dev/webview-cli","owner":"just-be-dev","description":"A webview CLI: render HTML, get back json","archived":false,"fork":false,"pushed_at":"2026-06-05T03:39:55.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-05T05:05:49.081Z","etag":null,"topics":["agents","cli","gui","html","rust","webview"],"latest_commit_sha":null,"homepage":"https://github.com/just-be-dev/webview-cli","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/just-be-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-05T01:18:07.000Z","updated_at":"2026-06-05T03:39:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/just-be-dev/webview-cli","commit_stats":null,"previous_names":["just-be-dev/webview-cli"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/just-be-dev/webview-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-be-dev%2Fwebview-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-be-dev%2Fwebview-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-be-dev%2Fwebview-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-be-dev%2Fwebview-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/just-be-dev","download_url":"https://codeload.github.com/just-be-dev/webview-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-be-dev%2Fwebview-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34623906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","cli","gui","html","rust","webview"],"created_at":"2026-06-21T20:01:40.083Z","updated_at":"2026-06-21T20:01:41.476Z","avatar_url":"https://github.com/just-be-dev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webview\n\nA webview CLI. It opens a native window, renders the HTML you give it,\ngives the page **one** channel to send a result back, prints that result, and\nexits. That's the whole tool.\n\nAny caller — a shell, an agent, Python, Node — integrates the same way: spawn\nthe process, write HTML, read the result off stdout.\n\nThe page does `JSON.stringify`; the binary prints that string **verbatim**. The\nRust side never parses or validates the result — its shape is entirely the\ncaller's concern.\n\n## Install\n\n**Install script** (macOS / Linux) — grabs the right prebuilt binary for your\nplatform from the latest GitHub release:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/just-be-dev/webview-cli/main/install.sh | sh\n```\n\n**Prebuilt binaries** — download from the\n[Releases page](https://github.com/just-be-dev/webview-cli/releases). Each\nrelease ships `webview-\u003cplatform\u003e` for `macos-arm64`, `linux-x64`,\n`linux-arm64`, and `windows-x64`, alongside `SHA256SUMS`.\n\n**Cargo** — if you have a Rust toolchain:\n\n```bash\ncargo install webview-cli      # installs the `webview` binary\n```\n\n**From source:**\n\n```bash\nmise run build                 # -\u003e target/release/webview\n# or\ncargo build --release\n```\n\nOn Linux you need the WebKitGTK headers to build (or to run the binary):\n`libwebkit2gtk-4.1-dev libgtk-3-dev`.\n\n## Usage\n\n```bash\necho '\u003chtml\u003e…\u003c/html\u003e' | webview            # HTML piped on stdin\nwebview ./page.html                         # or a file path\nwebview https://example.com                 # or an http(s) URL\nwebview ./page.html --title T --width 900 --height 700 --devtools --icon ./icon.png --timeout-ms 60000\n```\n\nInput precedence: non-empty piped stdin wins; otherwise the positional argument\n(an `http://`/`https://` URL is loaded remotely, anything else is treated as a\nfile); otherwise it's a usage error. File pages are served over a custom origin\nso relative CSS/JS/images and `fetch` resolve (and so they load at all under\nWKWebView).\n\n### Flags\n\n| Flag           | Default   | Meaning                                      |\n| -------------- | --------- | -------------------------------------------- |\n| `--title`      | `webview` | Window title.                                |\n| `--width`      | `800`     | Window width (logical px).                   |\n| `--height`     | `600`     | Window height (logical px).                  |\n| `--devtools`   | off       | Open dev tools on launch.                    |\n| `--icon`       | none      | Image to show as the Dock icon (macOS only). |\n| `--timeout-ms` | none      | Exit `3` if the page hasn't settled in time. |\n\nEverything else lives in the HTML — there are no other flags by design.\n\n## The bridge\n\nThe page talks back through one injected object:\n\n```js\nwindow.webview.version; // the webview-cli version string, e.g. \"0.2.0\"\nwindow.webview.resolve(value); // any JSON-serializable value\nwindow.webview.reject(error); // string or Error\n```\n\nThe first `resolve`/`reject` wins; the process exits immediately after.\n\n### Detecting the webview\n\nA page — especially one loaded from a URL — can tell it's running inside\n`webview` two ways:\n\n- **In JavaScript:** check for the injected object, e.g.\n  `if (window.webview) { … }`. `window.webview.version` disambiguates it from\n  any same-named global and tells you which build.\n- **Server-side / before any JS:** the User-Agent is set to\n  `webview-cli/\u003cversion\u003e (+https://github.com/just-be-dev/webview-cli)`, so a\n  server can detect the context and tailor the page on first byte.\n\n## Exit codes — this table _is_ the public API\n\n| Outcome                    | stdout              | stderr  | exit |\n| -------------------------- | ------------------- | ------- | ---- |\n| page called `resolve(v)`   | `JSON.stringify(v)` | —       | 0    |\n| page called `reject(e)`    | —                   | message | 1    |\n| user closed window first   | (empty)             | —       | 2    |\n| `--timeout-ms` elapsed     | (empty)             | —       | 3    |\n| bad usage (no input, etc.) | (empty)             | usage   | 64   |\n\n## End-to-end example\n\nA tiny confirmation prompt that returns `true`/`false`:\n\n```bash\ncat \u003c\u003c'HTML' | webview --title \"Confirm\" --width 360 --height 160\n\u003c!doctype html\u003e\n\u003cbody style=\"font:14px system-ui;display:grid;place-content:center;gap:12px\"\u003e\n  \u003cp\u003eDelete everything?\u003c/p\u003e\n  \u003cdiv\u003e\n    \u003cbutton onclick=\"webview.resolve(true)\"\u003eYes\u003c/button\u003e\n    \u003cbutton onclick=\"webview.resolve(false)\"\u003eNo\u003c/button\u003e\n  \u003c/div\u003e\n\u003c/body\u003e\nHTML\n# prints `true` or `false`; exit 0\n```\n\n## From an agent — the same call, three ways\n\nNo SDK: spawn the binary, write HTML to stdin, read stdout.\n\n**Shell**\n\n```bash\nresult=$(echo \"$html\" | webview --timeout-ms 60000)\n```\n\n**Python**\n\n```python\nimport subprocess\nout = subprocess.run([\"webview\", \"--timeout-ms\", \"60000\"],\n                     input=html, capture_output=True, text=True)\nresult = out.stdout                     # JSON string; parse if you want\n```\n\n**Node**\n\n```js\nimport { spawnSync } from \"node:child_process\";\nconst out = spawnSync(\"webview\", [\"--timeout-ms\", \"60000\"], { input: html });\nconst result = out.stdout.toString(); // JSON string\n```\n\n## The one boundary\n\n`webview` does \"show something, get one answer back\" — it isn't a live,\ntwo-way session. When you need multiple steps, put them all in one page (a\nwizard, several screens in one document) and only call `resolve` at the very\nend. Keep the interaction in the HTML.\n\n## Development\n\n```bash\nmise run test          # cargo test (window-launch tests skip without a display)\nmise run lint          # cargo clippy -D warnings\nmise run format        # cargo fmt\nmise run typecheck     # cargo check --all-targets\nmise run check         # all of the above\n```\n\nSource layout:\n\n| File        | Concern                                                   |\n| ----------- | --------------------------------------------------------- |\n| `main.rs`   | orchestration: parse args, resolve input, run             |\n| `cli.rs`    | clap arg struct + usage                                   |\n| `input.rs`  | stdin / URL / path resolution → a `Load` enum             |\n| `bridge.rs` | the `BRIDGE` JS + `AppEvent` + message parsing            |\n| `assets.rs` | custom-protocol file server (MIME, path-traversal safety) |\n| `icon.rs`   | runtime Dock-icon swap for `--icon` (macOS; no-op else)   |\n| `run.rs`    | window + webview build, event loop, exit codes            |\n\n## Releasing\n\nPushing a `v*` tag (e.g. `v0.1.0`) triggers the release workflow, which builds\nall four platform binaries, attaches them plus `SHA256SUMS` to a GitHub\nRelease, and publishes the crate to crates.io. See\n[`.github/workflows/release.yml`](.github/workflows/release.yml).\n\n## License\n\n[MIT](LICENSE) © Justin Bennett\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-be-dev%2Fwebview-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjust-be-dev%2Fwebview-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-be-dev%2Fwebview-cli/lists"}