You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Thelie 594ce55303 Added readmes to subprojects. 4 months ago
sing_macros Added readmes to subprojects. 4 months ago
sing_parse Added readmes to subprojects. 4 months ago
sing_util Added readmes to subprojects. 4 months ago
src Added copyright and license disclaimers to source files (#2) 5 months ago
.gitignore Initial commit 6 months ago
Cargo.toml Release 0.1.3 4 months ago Renamed license file 5 months ago Release 0.1.3 4 months ago Update '' 5 months ago





Generator License

What is sing?

This crate is meant to create interfaces between traits in Rust libraries and the command line. It does this by providing two macros:

  • sing_add_trait, which acts as an attribute to a trait implementation and gathers the method signatures that are used by sing_loop!.
  • sing_loop!, which takes a trait object and serialization/deserialization functions as well as some optional parameters. It generates a loop parsing function calls coming from STDIN (or any other BufRead stream), evaluating them by calling the appropriate method on the object and returning them on STDOUT (or any other Write stream).

Usage example

use serde::{Serialize, Deserialize};
use sing_rs::{sing_add_trait, sing_loop};

trait FruitTree {
         fn shake(&self, shakes: u32) -> Vec<Fruit>;

#[derive(Debug, Serialize, Deserialize)]
struct Fruit {
         fruit_type: String,

struct BananaTree;

impl FruitTree for BananaTree {
         fn shake(&self, shakes: u32) -> Vec<Fruit>{
                  let mut out = vec!();

                  for _ in 0..shakes {
                                out.push(Fruit{fruit_type: String::from("Banana")});

fn main() {
         let tree = BananaTree {};
    sing_loop!(tree, [different, ron::to_string, ron::from_str],);

Negotiator? Really?

Yes, it's somewhat far-fetched, but I really wanted to be able to sing and clap in my rusty command-line projects.

Why the name?

See above.