Skip to main content

Hypershell v0.1.0

This page lists what the first release of Hypershell provides. Hypershell is a domain-specific language for shell-script-like programs, built with Context-Generic Programming (CGP), a Rust library whose macros generate traits and their wiring: a program is a Rust type, and the context that runs it chooses how each step is carried out.

Released on 2025-06-13.

Summary​

The hypershell! macro writes a program as a type, in a syntax with a pipe operator, bracketed argument lists, and string literals. Each syntax type is a plain marker with no behavior, so the crates that interpret it are separate: native commands through Tokio, HTTP through reqwest, JSON, checksums, and WebSockets. Two contexts, HypershellCli and HypershellHttp, run a program, and the presets they are built from let an application add its own syntax and handlers.

Compatibility​

  • Minimum Rust version: 1.87, and the repository's toolchain file names the same stable release.
  • CGP version: requires cgp 0.4.1, and cgp-error-anyhow 0.4.1 supplies the contexts' anyhow error type.
  • Crates: hypershell, hypershell-components, hypershell-tokio-components, hypershell-reqwest-components, hypershell-json-components, hypershell-hash-components, hypershell-tungstenite-components, and hypershell-macro, all at 0.1.0.

Upgrading​

This is the project's first release, so there is nothing to upgrade from. Add hypershell beside cgp and an async runtime such as Tokio, and import hypershell::prelude::*.

New features​

The language​

  • hypershell!, in hypershell-macro, turns the program's shell-like syntax into a type: | becomes Pipe over a Product! list, a bracketed list becomes the step's arguments, and a bare string literal becomes a Symbol!.
  • Commands: SimpleExec runs a command and returns its output, StreamingExec streams its input and output, and StaticArg, FieldArg, WithStaticArgs, WithArgs, FieldArgs, JoinArgs, and UrlEncodeArg build its arguments from literals and context fields.
  • HTTP: SimpleHttpRequest and StreamingHttpRequest, with the methods GetMethod, PostMethod, PutMethod, and DeleteMethod, and Header and WithHeaders for headers.
  • Streams and files: StreamToStdout, StreamToBytes, StreamToString, BytesToStream, and BytesToString convert between stream and value forms, and ReadFile and WriteFile read and write files. StreamToLines has a handler, HandleStreamToLines, that no preset wires.
  • Data: EncodeJson and DecodeJson, ConvertTo for a conversion between types, and Checksum and BytesToHex in hypershell-hash-components.
  • Composition: Pipe runs steps in sequence, passing each output to the next, and Use<Provider, Code> hands its code to the handler Provider names; WebSocket connects to a WebSocket endpoint.

Interpretation​

  • hypershell-tokio-components runs commands as Tokio child processes and handles the stream and file steps.
  • hypershell-reqwest-components sends the HTTP steps with reqwest.
  • hypershell-json-components, hypershell-hash-components, and hypershell-tungstenite-components handle the JSON, checksum, and WebSocket steps, the last through tokio-tungstenite.

Contexts and presets​

  • HypershellCli, a context without fields, runs programs whose steps need nothing from the context, such as commands, streams, files, and JSON.
  • HypershellHttp has the same wiring and a reqwest Client in its http_client field, which the HTTP steps read.
  • Presets: the component crates other than hypershell-hash-components export cgp_preset! presets of their handlers, such as HypershellTokioPreset and HypershellReqwestPreset, and HypershellPreset combines them. An application builds its own preset on them to add syntax or replace a handler, as http_checksum_native does to add the checksum handlers.

Examples​

The hypershell-examples crate, which is not published, holds the programs the release post walks through, among them hello, hello_name, and http_checksum_native.


An AI agent wrote this page from the release's source changes and the CGP knowledge base. Its content was verified against the project's source at the release's tag. See How AI is used in this project.