All Projects → interact-rs → Interact

interact-rs / Interact

Licence: other
Online introspection for Rust

Programming Languages

rust
11053 projects
reflection
70 projects

Projects that are alternatives of or similar to Interact

Go Termd
Package termd provides terminal markdown rendering, with code block syntax highlighting support.
Stars: ✭ 223 (-10.8%)
Mutual labels:  command-line
Pack
📦 The missing vim8 package manager.
Stars: ✭ 238 (-4.8%)
Mutual labels:  command-line
Websocat
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
Stars: ✭ 3,477 (+1290.8%)
Mutual labels:  command-line
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (+949.2%)
Mutual labels:  command-line
Tutorials
🗒 codebar's tutorials
Stars: ✭ 231 (-7.6%)
Mutual labels:  command-line
Utern
Multi group and stream log tailing for AWS CloudWatch Logs.
Stars: ✭ 241 (-3.6%)
Mutual labels:  command-line
Hcl
Command-line tool for manipulating Harvest timesheets
Stars: ✭ 219 (-12.4%)
Mutual labels:  command-line
Hss
An interactive parallel ssh client featuring autocomplete and asynchronous execution.
Stars: ✭ 248 (-0.8%)
Mutual labels:  command-line
Meow
🐈 CLI app helper
Stars: ✭ 2,839 (+1035.6%)
Mutual labels:  command-line
Glacieruploader
A simple java command line application for Amazon Glacier
Stars: ✭ 245 (-2%)
Mutual labels:  command-line
Manssh
Manage your ssh alias configs easily.
Stars: ✭ 226 (-9.6%)
Mutual labels:  command-line
Aws Adfs
Command line tool to ease aws cli authentication against ADFS (multi factor authentication with active directory)
Stars: ✭ 229 (-8.4%)
Mutual labels:  command-line
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+1028.4%)
Mutual labels:  command-line
Gitlab Cli
Create a merge request from command line in gitlab
Stars: ✭ 224 (-10.4%)
Mutual labels:  command-line
Gif For Cli
opensource.googleblog.com/2018/06/tenor-gif-for-cli.html
Stars: ✭ 2,772 (+1008.8%)
Mutual labels:  command-line
Klog
A plain-text file format and command line tool for time tracking
Stars: ✭ 222 (-11.2%)
Mutual labels:  command-line
Mitype
Typing speed test in terminal
Stars: ✭ 241 (-3.6%)
Mutual labels:  command-line
Statik
Multi-purpose static web site generator aimed at developers.
Stars: ✭ 249 (-0.4%)
Mutual labels:  command-line
Doctl
The official command line interface for the DigitalOcean API.
Stars: ✭ 2,856 (+1042.4%)
Mutual labels:  command-line
Cli Matic
Compact, hands-free [sub]command line parsing library for Clojure.
Stars: ✭ 245 (-2%)
Mutual labels:  command-line

Interact   Build Status Latest Version Docs badge License badge

Interact is a framework for friendly online introspection of the running program state in an intuitive command-line interactive way.

You may be looking for:


Interact 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 method functions that were specified in interact derive attributes.

Interact is implemented for stable Rust, using only safe mode.

Introduction

While dynamically-typed interpreted languages offer the advantage of being able 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 aimes to provide a midway solution using stable Rust.

How to make your server Interact-able

  • Custom-derive types using #[derive(Interact)].
    • Use #[interact(skip) for problematic fields.
    • No need to worry about Rc, RefCell, Arc, Mutex, even with reference loops. Handling for that exists, as demonstrated further.
  • Register process-global or TLS-local state via interact_prompt's registry.
  • Invoke interact_prompt either directly or in its own OS thread (async not supported yet).

Interact Prompt features

  • Provide Rust-like expressions to explore from the root nodes, e.g. node.some_map["value"].field.sub_field.
  • Full auto-complete and completion hints for type names, field names, enum names, function names, and punctuation.
  • Modify the state from the prompt: at places where mutable access is possible in compile time, you can assign to fields of inner structs in run-time via appending = <value>.
  • It is possible to call method functions that were linked in using special interact attributes.
  • State prints have an adjustable limit - if the state is too big it can be automatically capped so your terminal is not overwhelmed.
  • Reference cycles (via Rc or otherwise) are handled gracefully in reflected values - a unique number is printed at the all the common sites: the first encounter and the repeats.
  • Data indirection is supported - for example Actix's Addr<T> can be traversed into, exposing the full server state (see the example in the book).

Interact mini-example with a recorded demo

The program below registers states and invokes the Interact prompt on the main thread.

extern crate interact;

use interact::Interact;
use interact_prompt::{LocalRegistry, Settings};
use std::{cell::RefCell, rc::Rc};

#[derive(Interact)]
struct Point {
    x: i32,
    y: i32,
}

#[derive(Interact)]
struct State {
    maybe_point: Option<Point>,
    complex: ((((usize, usize), u32, (u32, (u32,))), u32), u32),
    behind_rc: Rc<RefCell<u32>>,
    behind_rc2: Rc<RefCell<u32>>,
}

fn main() -> Result<(), interact_prompt::PromptError> {
    let rc = Rc::new(RefCell::new(3));
    let state = State {
        maybe_point: Some(Point { x: 3, y: 3 }),
        complex: ((((0, 0), 0, (0, (0,))), 0), 0),
        behind_rc: rc.clone(),
        behind_rc2: rc,
    };

    LocalRegistry::insert("state", Box::new(state));
    interact_prompt::direct(Settings::default(), ())?;
    Ok(())
}

(this is just one mode for using the Interact prompt. Another mode is running it in the background allowing to traverse, access, and modify global process state safeuly and without interference).

When cloning this repository, this it can be run using cargo run --example mini-example. Here's a recorded session:

Getting help

You are more than welcome to browse and open new issues!

License

Interact is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Interact by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].