Browse Source

Rework cli args

master
Dylan Baker 5 years ago
parent
commit
819f115ec3
3 changed files with 16 additions and 16 deletions
  1. 11
    11
      Cargo.lock
  2. 1
    0
      src/cli.rs
  3. 4
    5
      src/main.rs

+ 11
- 11
Cargo.lock View File

@@ -79,6 +79,17 @@ name = "bitflags"
79 79
 version = "1.0.4"
80 80
 source = "registry+https://github.com/rust-lang/crates.io-index"
81 81
 
82
+[[package]]
83
+name = "bnglws-client"
84
+version = "0.1.0"
85
+dependencies = [
86
+ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
87
+ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
88
+ "reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)",
89
+ "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
90
+ "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
91
+]
92
+
82 93
 [[package]]
83 94
 name = "build_const"
84 95
 version = "0.2.1"
@@ -340,17 +351,6 @@ dependencies = [
340 351
  "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
341 352
 ]
342 353
 
343
-[[package]]
344
-name = "gist-client"
345
-version = "0.1.0"
346
-dependencies = [
347
- "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
348
- "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
349
- "reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)",
350
- "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
351
- "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
352
-]
353
-
354 354
 [[package]]
355 355
 name = "h2"
356 356
 version = "0.1.18"

+ 1
- 0
src/cli.rs View File

@@ -38,6 +38,7 @@ fn get_server_config_from_matches(matches: &ArgMatches) -> ServerConfig {
38 38
 
39 39
 pub fn new_snippet(matches: &ArgMatches) -> io::Result<()> {
40 40
     let snippet = get_snippet_from_matches(matches)?;
41
+    println!("{:?}", snippet);
41 42
     let config = get_server_config_from_matches(matches);
42 43
 
43 44
     match create_snippet(snippet, &config) {

+ 4
- 5
src/main.rs View File

@@ -4,7 +4,7 @@ extern crate reqwest;
4 4
 extern crate serde;
5 5
 extern crate serde_json;
6 6
 
7
-use clap::{App, Arg, SubCommand};
7
+use clap::{App, AppSettings, Arg, SubCommand};
8 8
 use std::io;
9 9
 
10 10
 mod cli;
@@ -12,15 +12,14 @@ mod client;
12 12
 
13 13
 fn main() -> io::Result<()> {
14 14
     let matches = App::new("snippet")
15
-        .version("0.0.1")
15
+        .version("0.1.0")
16
+        .setting(AppSettings::ArgRequiredElseHelp)
16 17
         .subcommand(
17 18
             SubCommand::with_name("new")
18 19
                 .about("Creates a new snippet")
19 20
                 .arg(
20 21
                     Arg::with_name("name")
21
-                        .long("name")
22
-                        .short("n")
23
-                        .takes_value(true)
22
+                        .index(1)
24 23
                         .required(true)
25 24
                         .help("The name of the snippet"),
26 25
                 )

Loading…
Cancel
Save