{"id":13995348,"url":"https://github.com/interact-rs/interact","last_synced_at":"2025-07-22T21:32:41.594Z","repository":{"id":39758862,"uuid":"165545028","full_name":"interact-rs/interact","owner":"interact-rs","description":"Online introspection for Rust","archived":false,"fork":false,"pushed_at":"2022-05-27T13:01:31.000Z","size":2172,"stargazers_count":415,"open_issues_count":9,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-17T01:46:06.068Z","etag":null,"topics":["command-line","reflection","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interact-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-13T19:25:19.000Z","updated_at":"2024-11-12T05:18:19.000Z","dependencies_parsed_at":"2022-09-07T07:01:40.632Z","dependency_job_id":null,"html_url":"https://github.com/interact-rs/interact","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interact-rs%2Finteract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interact-rs%2Finteract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interact-rs%2Finteract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interact-rs%2Finteract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interact-rs","download_url":"https://codeload.github.com/interact-rs/interact/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227177921,"owners_count":17743201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["command-line","reflection","rust"],"created_at":"2024-08-09T14:03:21.655Z","updated_at":"2024-11-29T17:31:35.261Z","avatar_url":"https://github.com/interact-rs.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Interact \u0026emsp; [![Build Status]][travis] [![Latest Version]][crates.io] [![Docs badge]][Docs link] [![License badge]][License link]\n\n[Build Status]: https://api.travis-ci.org/interact-rs/interact.svg?branch=master\n[travis]: https://travis-ci.org/interact-rs/interact\n[Latest Version]: https://img.shields.io/crates/v/interact.svg\n[crates.io]: https://crates.io/crates/interact\n[License badge]: https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg\n[License link]: https://travis-ci.org/interact-rs/interact\n[Docs badge]: https://docs.rs/interact/badge.svg\n[Docs link]: https://docs.rs/interact\n\n**Interact is a framework for friendly online introspection of the running program state in an intuitive command-line *interact*ive way.**\n\nYou may be looking for:\n\n* [Book](https://interact-rs.github.io/interact/book/) (master).\n* Crate docs of `interact_prompt`: [latest](https://docs.rs/interact_prompt), [master](https://interact-rs.github.io/interact/doc/interact_prompt/index.html)\n* Crate docs of `interact`: [latest](https://docs.rs/interact), [master](https://interact-rs.github.io/interact/doc/interact/index.html)\n\n---\n\nInteract is useful for server programs that otherwise receive no input. You can use Interact to make your server receive commands using the special prompt from the `interact_prompt` crate. The commands can be used to browse your server's internal state, modify it, and call methods that were specified in `interact` derive attributes.\n\nInteract is implemented for stable Rust, using only safe mode.\n\n## Introduction\n\nWhile dynamically-typed interpreted languages offer the advantage of being able to look at a running program state using a prompt, compiled languages often do not provide that feature. Being hard as it is to introduce interpreters into compiled languages, the Interact project aims to provide a midway solution using stable Rust.\n\n## How to make your server Interact-able\n\n* Custom-derive types using `#[derive(Interact)]`.\n\t* Use `#[interact(skip)]` for problematic fields.\n\t* No need to worry about `Rc`, `RefCell`, `Arc`, or `Mutex`, even with reference loops. Handling for that exists, as demonstrated later.\n* Register process-global or TLS-local state via `interact_prompt`'s registry.\n* Invoke `interact_prompt` either directly or in its own OS thread (async not supported yet).\n\n## Interact Prompt features\n\n* Provide Rust-like expressions to explore from the root nodes, e.g. `node.some_map[\"value\"].field.sub_field`.\n* Full auto-complete and completion hints for type names, field names, enum names, function names, and punctuation.\n* Modify the state from the prompt: at places where mutable access is possible at compile-time, you can assign to fields of inner structs at run-time by appending `= \u003cvalue\u003e`.\n* It is possible to call methods that were linked using special `interact` attributes.\n* State prints have an adjustable limit - if the state is too big it can be automatically capped so your terminal is not overwhelmed.\n* Reference cycles (via `Rc` or otherwise) are handled gracefully in reflected values - a unique number is printed at all the common sites: the first encounter and the repeats.\n* Data indirection is supported - for example, Actix's `Addr\u003cT\u003e` can be traversed into, exposing the full server state (see the [example in the book](https://interact-rs.github.io/interact/book/examples/actix.html)).\n\n## Interact mini-example with a recorded demo\n\nThe program below registers states and invokes the Interact prompt on the main thread.\n\n```rust\nextern crate interact;\n\nuse interact::Interact;\nuse interact_prompt::{LocalRegistry, Settings};\nuse std::{cell::RefCell, rc::Rc};\n\n#[derive(Interact)]\nstruct Point {\n    x: i32,\n    y: i32,\n}\n\n#[derive(Interact)]\nstruct State {\n    maybe_point: Option\u003cPoint\u003e,\n    complex: ((((usize, usize), u32, (u32, (u32,))), u32), u32),\n    behind_rc: Rc\u003cRefCell\u003cu32\u003e\u003e,\n    behind_rc2: Rc\u003cRefCell\u003cu32\u003e\u003e,\n}\n\nfn main() -\u003e Result\u003c(), interact_prompt::PromptError\u003e {\n    let rc = Rc::new(RefCell::new(3));\n    let state = State {\n        maybe_point: Some(Point { x: 3, y: 3 }),\n        complex: ((((0, 0), 0, (0, (0,))), 0), 0),\n        behind_rc: rc.clone(),\n        behind_rc2: rc,\n    };\n\n    LocalRegistry::insert(\"state\", Box::new(state));\n    interact_prompt::direct(Settings::default(), ())?;\n    Ok(())\n}\n```\n\n(this is just one mode for using the Interact prompt. Another mode is running it in the background allowing it to traverse, access, and modify the global process state safely and without interference).\n\nWhen cloning this repository, it can be run using `cargo run --example mini-example`. Here's a recorded session:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"doc/demo.apng\"\u003e\n\u003c/p\u003e\n\n## Getting help\n\nYou are more than welcome to browse and open new issues!\n\n[issues]: https://github.com/interact-rs/interact/issues/new/choose\n\n## License\n\nInteract is licensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or\n   http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in Interact by you, as defined in the Apache-2.0 license, shall be\ndual-licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteract-rs%2Finteract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finteract-rs%2Finteract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteract-rs%2Finteract/lists"}