Browse Source

Use clap

master
Dylan Baker 5 years ago
parent
commit
71be194842
3 changed files with 147 additions and 1 deletions
  1. 117
    0
      Cargo.lock
  2. 1
    0
      Cargo.toml
  3. 29
    1
      src/main.rs

+ 117
- 0
Cargo.lock View File

@@ -6,11 +6,48 @@ dependencies = [
6 6
  "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
7 7
 ]
8 8
 
9
+[[package]]
10
+name = "ansi_term"
11
+version = "0.11.0"
12
+source = "registry+https://github.com/rust-lang/crates.io-index"
13
+dependencies = [
14
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
15
+]
16
+
17
+[[package]]
18
+name = "atty"
19
+version = "0.2.11"
20
+source = "registry+https://github.com/rust-lang/crates.io-index"
21
+dependencies = [
22
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
23
+ "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
24
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
25
+]
26
+
27
+[[package]]
28
+name = "bitflags"
29
+version = "1.0.4"
30
+source = "registry+https://github.com/rust-lang/crates.io-index"
31
+
9 32
 [[package]]
10 33
 name = "cfg-if"
11 34
 version = "0.1.6"
12 35
 source = "registry+https://github.com/rust-lang/crates.io-index"
13 36
 
37
+[[package]]
38
+name = "clap"
39
+version = "2.32.0"
40
+source = "registry+https://github.com/rust-lang/crates.io-index"
41
+dependencies = [
42
+ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
43
+ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
44
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
45
+ "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
46
+ "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
47
+ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
48
+ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
49
+]
50
+
14 51
 [[package]]
15 52
 name = "lazy_static"
16 53
 version = "1.2.0"
@@ -31,6 +68,19 @@ dependencies = [
31 68
  "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
32 69
 ]
33 70
 
71
+[[package]]
72
+name = "redox_syscall"
73
+version = "0.1.42"
74
+source = "registry+https://github.com/rust-lang/crates.io-index"
75
+
76
+[[package]]
77
+name = "redox_termios"
78
+version = "0.1.1"
79
+source = "registry+https://github.com/rust-lang/crates.io-index"
80
+dependencies = [
81
+ "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
82
+]
83
+
34 84
 [[package]]
35 85
 name = "regex"
36 86
 version = "1.0.6"
@@ -51,6 +101,29 @@ dependencies = [
51 101
  "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
52 102
 ]
53 103
 
104
+[[package]]
105
+name = "strsim"
106
+version = "0.7.0"
107
+source = "registry+https://github.com/rust-lang/crates.io-index"
108
+
109
+[[package]]
110
+name = "termion"
111
+version = "1.5.1"
112
+source = "registry+https://github.com/rust-lang/crates.io-index"
113
+dependencies = [
114
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
115
+ "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
116
+ "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
117
+]
118
+
119
+[[package]]
120
+name = "textwrap"
121
+version = "0.10.0"
122
+source = "registry+https://github.com/rust-lang/crates.io-index"
123
+dependencies = [
124
+ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
125
+]
126
+
54 127
 [[package]]
55 128
 name = "thread_local"
56 129
 version = "0.3.6"
@@ -63,6 +136,7 @@ dependencies = [
63 136
 name = "tlon"
64 137
 version = "0.1.0"
65 138
 dependencies = [
139
+ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
66 140
  "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
67 141
  "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
68 142
 ]
@@ -72,25 +146,68 @@ name = "ucd-util"
72 146
 version = "0.1.3"
73 147
 source = "registry+https://github.com/rust-lang/crates.io-index"
74 148
 
149
+[[package]]
150
+name = "unicode-width"
151
+version = "0.1.5"
152
+source = "registry+https://github.com/rust-lang/crates.io-index"
153
+
75 154
 [[package]]
76 155
 name = "utf8-ranges"
77 156
 version = "1.0.2"
78 157
 source = "registry+https://github.com/rust-lang/crates.io-index"
79 158
 
159
+[[package]]
160
+name = "vec_map"
161
+version = "0.8.1"
162
+source = "registry+https://github.com/rust-lang/crates.io-index"
163
+
80 164
 [[package]]
81 165
 name = "version_check"
82 166
 version = "0.1.5"
83 167
 source = "registry+https://github.com/rust-lang/crates.io-index"
84 168
 
169
+[[package]]
170
+name = "winapi"
171
+version = "0.3.6"
172
+source = "registry+https://github.com/rust-lang/crates.io-index"
173
+dependencies = [
174
+ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
175
+ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
176
+]
177
+
178
+[[package]]
179
+name = "winapi-i686-pc-windows-gnu"
180
+version = "0.4.0"
181
+source = "registry+https://github.com/rust-lang/crates.io-index"
182
+
183
+[[package]]
184
+name = "winapi-x86_64-pc-windows-gnu"
185
+version = "0.4.0"
186
+source = "registry+https://github.com/rust-lang/crates.io-index"
187
+
85 188
 [metadata]
86 189
 "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
190
+"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
191
+"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
192
+"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
87 193
 "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
194
+"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
88 195
 "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
89 196
 "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
90 197
 "checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16"
198
+"checksum redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cf8fb82a4d1c9b28f1c26c574a5b541f5ffb4315f6c9a791fa47b6a04438fe93"
199
+"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
91 200
 "checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467"
92 201
 "checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e"
202
+"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
203
+"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
204
+"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
93 205
 "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
94 206
 "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
207
+"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
95 208
 "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
209
+"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
96 210
 "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
211
+"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
212
+"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
213
+"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

+ 1
- 0
Cargo.toml View File

@@ -4,5 +4,6 @@ version = "0.1.0"
4 4
 authors = ["Dylan Baker"]
5 5
 
6 6
 [dependencies]
7
+clap = "2.32.0"
7 8
 lazy_static = "1.2.0"
8 9
 regex = "1"

+ 29
- 1
src/main.rs View File

@@ -1,3 +1,4 @@
1
+extern crate clap;
1 2
 #[macro_use]
2 3
 extern crate lazy_static;
3 4
 extern crate regex;
@@ -6,6 +7,7 @@ use std::env;
6 7
 use std::fs;
7 8
 use std::path;
8 9
 
10
+use clap::{App, Arg};
9 11
 use regex::Regex;
10 12
 
11 13
 #[derive(Debug)]
@@ -76,7 +78,7 @@ fn render_post_listing(cwd: &path::PathBuf, layout: &str, post_item_template: &s
76 78
     fs::write(cwd.join("public").join("index.html"), &output).expect("Unable to write file");
77 79
 }
78 80
 
79
-fn main() {
81
+fn build() {
80 82
     let cwd = env::current_dir().expect("Couldn't read current directory");
81 83
 
82 84
     match fs::create_dir(cwd.join("public")) {
@@ -110,3 +112,29 @@ fn main() {
110 112
 
111 113
     render_post_listing(&cwd, &layout_template, &post_item_template, &posts);
112 114
 }
115
+
116
+fn new(name: &str) {}
117
+
118
+fn main() {
119
+    let matches = App::new("tlon")
120
+        .version("0.1.0")
121
+        .author("Dylan Baker")
122
+        .about("Highly opinionated static site generator")
123
+        .arg(
124
+            Arg::with_name("command")
125
+                .required(true)
126
+                .possible_values(&["build", "new"])
127
+                .index(1),
128
+        ).arg(
129
+            Arg::with_name("name")
130
+                .required_if("command", "new")
131
+                .index(2),
132
+        ).get_matches();
133
+
134
+    let command = matches.value_of("command").unwrap();
135
+    if command == "build" {
136
+        build();
137
+    } else if command == "new" {
138
+        new(&matches.value_of("name").unwrap());
139
+    }
140
+}

Loading…
Cancel
Save