cog 0.1.0

Simple, opiniated library for building Cog commands in rust.
Documentation
  • Coverage
  • 0%
    0 out of 14 items documented0 out of 9 items with examples
  • Size
  • Source code size: 6.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.01 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • pauldub/cog-rust
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • pauldub

cog-rust

Simple, opiniated library for building Cog commands in rust.

Getting Started

These instructions will get you a copy of the project up and running for use in your own bundles.

Prerequisities

# Cargo.toml
[dependencies]
cog = "0.1"

Usage

Write your bundle:

// main.rs
extern crate cog;

fn main() {
  let res = cog::Bundle::new("my-bundle")
    .command("hello", &hello_world)
    .run()
    .expect("failed to run bundle");
}

// cog::Args is a Vec<String> and cog::Opts a HashMap<String,String>
fn hello_word(args: cog::Args, opts: cog::Opts) {
  match cog.get("name") {
    Some(name) =>
      cog::write(&format!("hello {}", name)),
    None =>
      cog::write("hello world"),
  }
}

Use the resulting executable in cog's config.yaml:

commands:
  hello:
    executable: /usr/local/bin/my-bundle
    documentation: hello [--name=<name>]
    # ...

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us. So far this file does not exist, help welcome on how to handle this.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Paul d'Hubert - Initial work - pauldub

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • operable for bringing cog and the nice bundle system!