3 releases

0.1.6 Mar 19, 2024
0.1.5 Sep 24, 2023
0.1.4 Jul 20, 2023

#35 in #crud

Download history 1/week @ 2024-02-14 21/week @ 2024-02-21 16/week @ 2024-02-28 2/week @ 2024-03-06 120/week @ 2024-03-13 62/week @ 2024-03-20 31/week @ 2024-03-27 46/week @ 2024-04-03

260 downloads per month
Used in 4 crates (via crud-pretty-struct)

MIT license

11KB
220 lines

CRUD

A rust workspace to create command line interfaces (CLI) to HTTP API.

For example, you can create a CLI for jsonplaceholder with this sniplet:

#[derive(Debug, Crud, Deserialize, Serialize, Default)]
struct Posts {
  #[crud(id, no_short)]
  id: u32,
  #[crud(help = "post author's id")]
  #[serde(rename = "userId")]
  user_id: u32,
  #[crud(help = "title of the post")]
  #[crud(no_short)]
  title: String,
  #[crud(help = "body of the post")]
  body: String,
}

After compiling (and some boitlerplates; uses, main function, ...), you'll obtain:

$ jsonplaceholder posts -h
Posts listing

Usage: jsonplaceholder posts [OPTIONS] [id] [COMMAND]

Commands:
  create    Posts creation
  delete    Posts deletion
  update    Posts update
  replace   Posts replacement
  help      Print this message or the help of the given subcommand(s)

Arguments:
  [id]

Options:
  -h, --help  Print help information (use `--help` for more detail)
$ jsonplaceholder posts create -h
Posts creation

Usage: jsonplaceholder posts create [OPTIONS] --user_id <user_id> --title <title> --body <body>

Options:
  -h, --help  Print help information (use `--help` for more detail)

Payload:
  -u, --user_id <user_id>  post author's id
      --title <title>      title of the post
  -b, --body <body>        body of the post

The complete code of this example is at ./crud/examples/jsonplaceholder.rs

Sub Crates

Dependencies

~0.8–1.3MB
~28K SLoC