Browse Source

Command line options

master
Julio Biason 4 years ago
commit
6e666bc76e
  1. 1
      .gitignore
  2. 113
      Cargo.lock
  3. 10
      Cargo.toml
  4. 45
      src/main.rs

1
.gitignore vendored

@ -0,0 +1 @@
/target

113
Cargo.lock generated

@ -0,0 +1,113 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "clap"
version = "2.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "hermit-abi"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
dependencies = [
"libc",
]
[[package]]
name = "libc"
version = "0.2.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
[[package]]
name = "nrp"
version = "0.1.0"
dependencies = [
"clap",
]
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "unicode-width"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
[[package]]
name = "vec_map"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
[[package]]
name = "winapi"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

10
Cargo.toml

@ -0,0 +1,10 @@
[package]
name = "nrp"
version = "0.1.0"
authors = ["Julio Biason <julio.biason@pm.me>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = "2.33.0"

45
src/main.rs

@ -0,0 +1,45 @@
use clap::{Arg, App, SubCommand};
fn main() {
let generate = SubCommand::with_name("generate")
.about("Generate a new name")
.arg(Arg::with_name("description")
.help("Short description of your application"));
let adjectives = SubCommand::with_name("adjectives")
.about("Adjectives maintenance")
.subcommand(SubCommand::with_name("list")
.about("List current adjectives"))
.subcommand(SubCommand::with_name("add")
.about("Add a new adjective")
.arg(Arg::with_name("adjective")
.help("Adjective to be added")))
.subcommand(SubCommand::with_name("rm")
.about("Remove an adjective")
.arg(Arg::with_name("adjective")
.help("Adjective to be removed")));
let metals = SubCommand::with_name("metals")
.about("Metal names maintenance")
.subcommand(SubCommand::with_name("list")
.about("List current metal names"))
.subcommand(SubCommand::with_name("add")
.about("Add a new metal name")
.arg(Arg::with_name("adjective")
.help("Metal name to be added")))
.subcommand(SubCommand::with_name("rm")
.about("Remove a metal name")
.arg(Arg::with_name("adjective")
.help("Metal name to be removed")));
let main = App::new("Name Rust Programs")
.version("0.1")
.author("Julio Biason <julio.biason@pm.me>")
.about("From a short description, create a name for your application")
.subcommand(generate)
.subcommand(adjectives)
.subcommand(metals);
let matches = main.get_matches();
dbg!(matches);
}
Loading…
Cancel
Save