├── .github
└── workflows
│ ├── publish.yml
│ └── test.yml
├── .gitignore
├── Cargo.lock
├── Cargo.toml
├── README.md
├── assets
└── usage.gif
├── cdwe.toml
├── shells
├── cdwe_bash.txt
├── cdwe_fish.txt
└── cdwe_zsh.txt
└── src
├── cache.rs
├── cmd
├── cmd.rs
├── init.rs
├── mod.rs
├── run.rs
└── shell.rs
├── config.rs
├── main.rs
└── utils.rs
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | tags:
4 | - '*'
5 | workflow_dispatch:
6 |
7 | name: Publish
8 |
9 | jobs:
10 | publish:
11 | name: Publish
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Checkout sources
15 | uses: actions/checkout@v2
16 |
17 | - name: Install stable toolchain
18 | uses: actions-rs/toolchain@v1
19 | with:
20 | profile: minimal
21 | toolchain: stable
22 | override: true
23 |
24 | - run: cargo publish --token ${CRATES_API_KEY}
25 | env:
26 | CRATES_API_KEY: ${{ secrets.CRATES_API_KEY }}
27 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | branches:
4 | - main
5 |
6 | name: Test
7 |
8 | jobs:
9 | test:
10 | name: Test
11 | runs-on: ubuntu-latest
12 | steps:
13 | - name: Checkout sources
14 | uses: actions/checkout@v2
15 |
16 | - name: Install stable toolchain
17 | uses: actions-rs/toolchain@v1
18 | with:
19 | profile: minimal
20 | toolchain: stable
21 | override: true
22 |
23 | - run: cargo test
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | debug/
4 | target/
5 |
6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8 | Cargo.lock
9 |
10 | # These are backup files generated by rustfmt
11 | **/*.rs.bk
12 |
13 | # MSVC Windows builds of rustc generate these, which store debugging information
14 | *.pdbtarget
15 |
--------------------------------------------------------------------------------
/Cargo.lock:
--------------------------------------------------------------------------------
1 | # This file is automatically @generated by Cargo.
2 | # It is not intended for manual editing.
3 | version = 3
4 |
5 | [[package]]
6 | name = "addr2line"
7 | version = "0.22.0"
8 | source = "registry+https://github.com/rust-lang/crates.io-index"
9 | checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
10 | dependencies = [
11 | "gimli",
12 | ]
13 |
14 | [[package]]
15 | name = "adler"
16 | version = "1.0.2"
17 | source = "registry+https://github.com/rust-lang/crates.io-index"
18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
19 |
20 | [[package]]
21 | name = "aho-corasick"
22 | version = "1.1.3"
23 | source = "registry+https://github.com/rust-lang/crates.io-index"
24 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
25 | dependencies = [
26 | "memchr",
27 | ]
28 |
29 | [[package]]
30 | name = "anstream"
31 | version = "0.3.2"
32 | source = "registry+https://github.com/rust-lang/crates.io-index"
33 | checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
34 | dependencies = [
35 | "anstyle",
36 | "anstyle-parse",
37 | "anstyle-query",
38 | "anstyle-wincon",
39 | "colorchoice",
40 | "is-terminal",
41 | "utf8parse",
42 | ]
43 |
44 | [[package]]
45 | name = "anstyle"
46 | version = "1.0.1"
47 | source = "registry+https://github.com/rust-lang/crates.io-index"
48 | checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
49 |
50 | [[package]]
51 | name = "anstyle-parse"
52 | version = "0.2.1"
53 | source = "registry+https://github.com/rust-lang/crates.io-index"
54 | checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333"
55 | dependencies = [
56 | "utf8parse",
57 | ]
58 |
59 | [[package]]
60 | name = "anstyle-query"
61 | version = "1.0.0"
62 | source = "registry+https://github.com/rust-lang/crates.io-index"
63 | checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
64 | dependencies = [
65 | "windows-sys 0.48.0",
66 | ]
67 |
68 | [[package]]
69 | name = "anstyle-wincon"
70 | version = "1.0.1"
71 | source = "registry+https://github.com/rust-lang/crates.io-index"
72 | checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
73 | dependencies = [
74 | "anstyle",
75 | "windows-sys 0.48.0",
76 | ]
77 |
78 | [[package]]
79 | name = "anyhow"
80 | version = "1.0.72"
81 | source = "registry+https://github.com/rust-lang/crates.io-index"
82 | checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854"
83 |
84 | [[package]]
85 | name = "autocfg"
86 | version = "1.3.0"
87 | source = "registry+https://github.com/rust-lang/crates.io-index"
88 | checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
89 |
90 | [[package]]
91 | name = "backtrace"
92 | version = "0.3.72"
93 | source = "registry+https://github.com/rust-lang/crates.io-index"
94 | checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11"
95 | dependencies = [
96 | "addr2line",
97 | "cc",
98 | "cfg-if",
99 | "libc",
100 | "miniz_oxide",
101 | "object",
102 | "rustc-demangle",
103 | ]
104 |
105 | [[package]]
106 | name = "bitflags"
107 | version = "1.3.2"
108 | source = "registry+https://github.com/rust-lang/crates.io-index"
109 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
110 |
111 | [[package]]
112 | name = "bitflags"
113 | version = "2.3.3"
114 | source = "registry+https://github.com/rust-lang/crates.io-index"
115 | checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
116 |
117 | [[package]]
118 | name = "block-buffer"
119 | version = "0.10.4"
120 | source = "registry+https://github.com/rust-lang/crates.io-index"
121 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
122 | dependencies = [
123 | "generic-array",
124 | ]
125 |
126 | [[package]]
127 | name = "bytes"
128 | version = "1.6.0"
129 | source = "registry+https://github.com/rust-lang/crates.io-index"
130 | checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
131 |
132 | [[package]]
133 | name = "cc"
134 | version = "1.0.98"
135 | source = "registry+https://github.com/rust-lang/crates.io-index"
136 | checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f"
137 |
138 | [[package]]
139 | name = "cdwe"
140 | version = "0.3.0"
141 | dependencies = [
142 | "anyhow",
143 | "clap",
144 | "regex",
145 | "serde",
146 | "serde_json",
147 | "sha2",
148 | "tokio",
149 | "toml",
150 | ]
151 |
152 | [[package]]
153 | name = "cfg-if"
154 | version = "1.0.0"
155 | source = "registry+https://github.com/rust-lang/crates.io-index"
156 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
157 |
158 | [[package]]
159 | name = "clap"
160 | version = "4.3.12"
161 | source = "registry+https://github.com/rust-lang/crates.io-index"
162 | checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73"
163 | dependencies = [
164 | "clap_builder",
165 | "clap_derive",
166 | "once_cell",
167 | ]
168 |
169 | [[package]]
170 | name = "clap_builder"
171 | version = "4.3.12"
172 | source = "registry+https://github.com/rust-lang/crates.io-index"
173 | checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd"
174 | dependencies = [
175 | "anstream",
176 | "anstyle",
177 | "clap_lex",
178 | "strsim",
179 | ]
180 |
181 | [[package]]
182 | name = "clap_derive"
183 | version = "4.3.12"
184 | source = "registry+https://github.com/rust-lang/crates.io-index"
185 | checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050"
186 | dependencies = [
187 | "heck",
188 | "proc-macro2",
189 | "quote",
190 | "syn",
191 | ]
192 |
193 | [[package]]
194 | name = "clap_lex"
195 | version = "0.5.0"
196 | source = "registry+https://github.com/rust-lang/crates.io-index"
197 | checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
198 |
199 | [[package]]
200 | name = "colorchoice"
201 | version = "1.0.0"
202 | source = "registry+https://github.com/rust-lang/crates.io-index"
203 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
204 |
205 | [[package]]
206 | name = "cpufeatures"
207 | version = "0.2.12"
208 | source = "registry+https://github.com/rust-lang/crates.io-index"
209 | checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
210 | dependencies = [
211 | "libc",
212 | ]
213 |
214 | [[package]]
215 | name = "crypto-common"
216 | version = "0.1.6"
217 | source = "registry+https://github.com/rust-lang/crates.io-index"
218 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
219 | dependencies = [
220 | "generic-array",
221 | "typenum",
222 | ]
223 |
224 | [[package]]
225 | name = "digest"
226 | version = "0.10.7"
227 | source = "registry+https://github.com/rust-lang/crates.io-index"
228 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
229 | dependencies = [
230 | "block-buffer",
231 | "crypto-common",
232 | ]
233 |
234 | [[package]]
235 | name = "equivalent"
236 | version = "1.0.1"
237 | source = "registry+https://github.com/rust-lang/crates.io-index"
238 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
239 |
240 | [[package]]
241 | name = "errno"
242 | version = "0.3.1"
243 | source = "registry+https://github.com/rust-lang/crates.io-index"
244 | checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
245 | dependencies = [
246 | "errno-dragonfly",
247 | "libc",
248 | "windows-sys 0.48.0",
249 | ]
250 |
251 | [[package]]
252 | name = "errno-dragonfly"
253 | version = "0.1.2"
254 | source = "registry+https://github.com/rust-lang/crates.io-index"
255 | checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
256 | dependencies = [
257 | "cc",
258 | "libc",
259 | ]
260 |
261 | [[package]]
262 | name = "generic-array"
263 | version = "0.14.7"
264 | source = "registry+https://github.com/rust-lang/crates.io-index"
265 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
266 | dependencies = [
267 | "typenum",
268 | "version_check",
269 | ]
270 |
271 | [[package]]
272 | name = "gimli"
273 | version = "0.29.0"
274 | source = "registry+https://github.com/rust-lang/crates.io-index"
275 | checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
276 |
277 | [[package]]
278 | name = "hashbrown"
279 | version = "0.14.0"
280 | source = "registry+https://github.com/rust-lang/crates.io-index"
281 | checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
282 |
283 | [[package]]
284 | name = "heck"
285 | version = "0.4.1"
286 | source = "registry+https://github.com/rust-lang/crates.io-index"
287 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
288 |
289 | [[package]]
290 | name = "hermit-abi"
291 | version = "0.3.2"
292 | source = "registry+https://github.com/rust-lang/crates.io-index"
293 | checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
294 |
295 | [[package]]
296 | name = "indexmap"
297 | version = "2.0.0"
298 | source = "registry+https://github.com/rust-lang/crates.io-index"
299 | checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
300 | dependencies = [
301 | "equivalent",
302 | "hashbrown",
303 | ]
304 |
305 | [[package]]
306 | name = "is-terminal"
307 | version = "0.4.9"
308 | source = "registry+https://github.com/rust-lang/crates.io-index"
309 | checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
310 | dependencies = [
311 | "hermit-abi",
312 | "rustix",
313 | "windows-sys 0.48.0",
314 | ]
315 |
316 | [[package]]
317 | name = "itoa"
318 | version = "1.0.11"
319 | source = "registry+https://github.com/rust-lang/crates.io-index"
320 | checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
321 |
322 | [[package]]
323 | name = "libc"
324 | version = "0.2.155"
325 | source = "registry+https://github.com/rust-lang/crates.io-index"
326 | checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
327 |
328 | [[package]]
329 | name = "linux-raw-sys"
330 | version = "0.4.3"
331 | source = "registry+https://github.com/rust-lang/crates.io-index"
332 | checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0"
333 |
334 | [[package]]
335 | name = "lock_api"
336 | version = "0.4.12"
337 | source = "registry+https://github.com/rust-lang/crates.io-index"
338 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
339 | dependencies = [
340 | "autocfg",
341 | "scopeguard",
342 | ]
343 |
344 | [[package]]
345 | name = "memchr"
346 | version = "2.7.2"
347 | source = "registry+https://github.com/rust-lang/crates.io-index"
348 | checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
349 |
350 | [[package]]
351 | name = "miniz_oxide"
352 | version = "0.7.3"
353 | source = "registry+https://github.com/rust-lang/crates.io-index"
354 | checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae"
355 | dependencies = [
356 | "adler",
357 | ]
358 |
359 | [[package]]
360 | name = "mio"
361 | version = "0.8.11"
362 | source = "registry+https://github.com/rust-lang/crates.io-index"
363 | checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
364 | dependencies = [
365 | "libc",
366 | "wasi",
367 | "windows-sys 0.48.0",
368 | ]
369 |
370 | [[package]]
371 | name = "num_cpus"
372 | version = "1.16.0"
373 | source = "registry+https://github.com/rust-lang/crates.io-index"
374 | checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
375 | dependencies = [
376 | "hermit-abi",
377 | "libc",
378 | ]
379 |
380 | [[package]]
381 | name = "object"
382 | version = "0.35.0"
383 | source = "registry+https://github.com/rust-lang/crates.io-index"
384 | checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e"
385 | dependencies = [
386 | "memchr",
387 | ]
388 |
389 | [[package]]
390 | name = "once_cell"
391 | version = "1.18.0"
392 | source = "registry+https://github.com/rust-lang/crates.io-index"
393 | checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
394 |
395 | [[package]]
396 | name = "parking_lot"
397 | version = "0.12.1"
398 | source = "registry+https://github.com/rust-lang/crates.io-index"
399 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
400 | dependencies = [
401 | "lock_api",
402 | "parking_lot_core",
403 | ]
404 |
405 | [[package]]
406 | name = "parking_lot_core"
407 | version = "0.9.9"
408 | source = "registry+https://github.com/rust-lang/crates.io-index"
409 | checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
410 | dependencies = [
411 | "cfg-if",
412 | "libc",
413 | "redox_syscall",
414 | "smallvec",
415 | "windows-targets 0.48.1",
416 | ]
417 |
418 | [[package]]
419 | name = "pin-project-lite"
420 | version = "0.2.14"
421 | source = "registry+https://github.com/rust-lang/crates.io-index"
422 | checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
423 |
424 | [[package]]
425 | name = "proc-macro2"
426 | version = "1.0.84"
427 | source = "registry+https://github.com/rust-lang/crates.io-index"
428 | checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6"
429 | dependencies = [
430 | "unicode-ident",
431 | ]
432 |
433 | [[package]]
434 | name = "quote"
435 | version = "1.0.36"
436 | source = "registry+https://github.com/rust-lang/crates.io-index"
437 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
438 | dependencies = [
439 | "proc-macro2",
440 | ]
441 |
442 | [[package]]
443 | name = "redox_syscall"
444 | version = "0.4.1"
445 | source = "registry+https://github.com/rust-lang/crates.io-index"
446 | checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
447 | dependencies = [
448 | "bitflags 1.3.2",
449 | ]
450 |
451 | [[package]]
452 | name = "regex"
453 | version = "1.10.4"
454 | source = "registry+https://github.com/rust-lang/crates.io-index"
455 | checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
456 | dependencies = [
457 | "aho-corasick",
458 | "memchr",
459 | "regex-automata",
460 | "regex-syntax",
461 | ]
462 |
463 | [[package]]
464 | name = "regex-automata"
465 | version = "0.4.6"
466 | source = "registry+https://github.com/rust-lang/crates.io-index"
467 | checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
468 | dependencies = [
469 | "aho-corasick",
470 | "memchr",
471 | "regex-syntax",
472 | ]
473 |
474 | [[package]]
475 | name = "regex-syntax"
476 | version = "0.8.3"
477 | source = "registry+https://github.com/rust-lang/crates.io-index"
478 | checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
479 |
480 | [[package]]
481 | name = "rustc-demangle"
482 | version = "0.1.24"
483 | source = "registry+https://github.com/rust-lang/crates.io-index"
484 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
485 |
486 | [[package]]
487 | name = "rustix"
488 | version = "0.38.4"
489 | source = "registry+https://github.com/rust-lang/crates.io-index"
490 | checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5"
491 | dependencies = [
492 | "bitflags 2.3.3",
493 | "errno",
494 | "libc",
495 | "linux-raw-sys",
496 | "windows-sys 0.48.0",
497 | ]
498 |
499 | [[package]]
500 | name = "ryu"
501 | version = "1.0.18"
502 | source = "registry+https://github.com/rust-lang/crates.io-index"
503 | checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
504 |
505 | [[package]]
506 | name = "scopeguard"
507 | version = "1.2.0"
508 | source = "registry+https://github.com/rust-lang/crates.io-index"
509 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
510 |
511 | [[package]]
512 | name = "serde"
513 | version = "1.0.203"
514 | source = "registry+https://github.com/rust-lang/crates.io-index"
515 | checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
516 | dependencies = [
517 | "serde_derive",
518 | ]
519 |
520 | [[package]]
521 | name = "serde_derive"
522 | version = "1.0.203"
523 | source = "registry+https://github.com/rust-lang/crates.io-index"
524 | checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
525 | dependencies = [
526 | "proc-macro2",
527 | "quote",
528 | "syn",
529 | ]
530 |
531 | [[package]]
532 | name = "serde_json"
533 | version = "1.0.117"
534 | source = "registry+https://github.com/rust-lang/crates.io-index"
535 | checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
536 | dependencies = [
537 | "itoa",
538 | "ryu",
539 | "serde",
540 | ]
541 |
542 | [[package]]
543 | name = "serde_spanned"
544 | version = "0.6.3"
545 | source = "registry+https://github.com/rust-lang/crates.io-index"
546 | checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186"
547 | dependencies = [
548 | "serde",
549 | ]
550 |
551 | [[package]]
552 | name = "sha2"
553 | version = "0.10.8"
554 | source = "registry+https://github.com/rust-lang/crates.io-index"
555 | checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
556 | dependencies = [
557 | "cfg-if",
558 | "cpufeatures",
559 | "digest",
560 | ]
561 |
562 | [[package]]
563 | name = "signal-hook-registry"
564 | version = "1.4.1"
565 | source = "registry+https://github.com/rust-lang/crates.io-index"
566 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
567 | dependencies = [
568 | "libc",
569 | ]
570 |
571 | [[package]]
572 | name = "smallvec"
573 | version = "1.13.2"
574 | source = "registry+https://github.com/rust-lang/crates.io-index"
575 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
576 |
577 | [[package]]
578 | name = "socket2"
579 | version = "0.5.6"
580 | source = "registry+https://github.com/rust-lang/crates.io-index"
581 | checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871"
582 | dependencies = [
583 | "libc",
584 | "windows-sys 0.52.0",
585 | ]
586 |
587 | [[package]]
588 | name = "strsim"
589 | version = "0.10.0"
590 | source = "registry+https://github.com/rust-lang/crates.io-index"
591 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
592 |
593 | [[package]]
594 | name = "syn"
595 | version = "2.0.66"
596 | source = "registry+https://github.com/rust-lang/crates.io-index"
597 | checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
598 | dependencies = [
599 | "proc-macro2",
600 | "quote",
601 | "unicode-ident",
602 | ]
603 |
604 | [[package]]
605 | name = "tokio"
606 | version = "1.38.0"
607 | source = "registry+https://github.com/rust-lang/crates.io-index"
608 | checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
609 | dependencies = [
610 | "backtrace",
611 | "bytes",
612 | "libc",
613 | "mio",
614 | "num_cpus",
615 | "parking_lot",
616 | "pin-project-lite",
617 | "signal-hook-registry",
618 | "socket2",
619 | "tokio-macros",
620 | "windows-sys 0.48.0",
621 | ]
622 |
623 | [[package]]
624 | name = "tokio-macros"
625 | version = "2.3.0"
626 | source = "registry+https://github.com/rust-lang/crates.io-index"
627 | checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
628 | dependencies = [
629 | "proc-macro2",
630 | "quote",
631 | "syn",
632 | ]
633 |
634 | [[package]]
635 | name = "toml"
636 | version = "0.7.6"
637 | source = "registry+https://github.com/rust-lang/crates.io-index"
638 | checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542"
639 | dependencies = [
640 | "serde",
641 | "serde_spanned",
642 | "toml_datetime",
643 | "toml_edit",
644 | ]
645 |
646 | [[package]]
647 | name = "toml_datetime"
648 | version = "0.6.3"
649 | source = "registry+https://github.com/rust-lang/crates.io-index"
650 | checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
651 | dependencies = [
652 | "serde",
653 | ]
654 |
655 | [[package]]
656 | name = "toml_edit"
657 | version = "0.19.14"
658 | source = "registry+https://github.com/rust-lang/crates.io-index"
659 | checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
660 | dependencies = [
661 | "indexmap",
662 | "serde",
663 | "serde_spanned",
664 | "toml_datetime",
665 | "winnow",
666 | ]
667 |
668 | [[package]]
669 | name = "typenum"
670 | version = "1.17.0"
671 | source = "registry+https://github.com/rust-lang/crates.io-index"
672 | checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
673 |
674 | [[package]]
675 | name = "unicode-ident"
676 | version = "1.0.11"
677 | source = "registry+https://github.com/rust-lang/crates.io-index"
678 | checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
679 |
680 | [[package]]
681 | name = "utf8parse"
682 | version = "0.2.1"
683 | source = "registry+https://github.com/rust-lang/crates.io-index"
684 | checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
685 |
686 | [[package]]
687 | name = "version_check"
688 | version = "0.9.4"
689 | source = "registry+https://github.com/rust-lang/crates.io-index"
690 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
691 |
692 | [[package]]
693 | name = "wasi"
694 | version = "0.11.0+wasi-snapshot-preview1"
695 | source = "registry+https://github.com/rust-lang/crates.io-index"
696 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
697 |
698 | [[package]]
699 | name = "windows-sys"
700 | version = "0.48.0"
701 | source = "registry+https://github.com/rust-lang/crates.io-index"
702 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
703 | dependencies = [
704 | "windows-targets 0.48.1",
705 | ]
706 |
707 | [[package]]
708 | name = "windows-sys"
709 | version = "0.52.0"
710 | source = "registry+https://github.com/rust-lang/crates.io-index"
711 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
712 | dependencies = [
713 | "windows-targets 0.52.5",
714 | ]
715 |
716 | [[package]]
717 | name = "windows-targets"
718 | version = "0.48.1"
719 | source = "registry+https://github.com/rust-lang/crates.io-index"
720 | checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
721 | dependencies = [
722 | "windows_aarch64_gnullvm 0.48.0",
723 | "windows_aarch64_msvc 0.48.0",
724 | "windows_i686_gnu 0.48.0",
725 | "windows_i686_msvc 0.48.0",
726 | "windows_x86_64_gnu 0.48.0",
727 | "windows_x86_64_gnullvm 0.48.0",
728 | "windows_x86_64_msvc 0.48.0",
729 | ]
730 |
731 | [[package]]
732 | name = "windows-targets"
733 | version = "0.52.5"
734 | source = "registry+https://github.com/rust-lang/crates.io-index"
735 | checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
736 | dependencies = [
737 | "windows_aarch64_gnullvm 0.52.5",
738 | "windows_aarch64_msvc 0.52.5",
739 | "windows_i686_gnu 0.52.5",
740 | "windows_i686_gnullvm",
741 | "windows_i686_msvc 0.52.5",
742 | "windows_x86_64_gnu 0.52.5",
743 | "windows_x86_64_gnullvm 0.52.5",
744 | "windows_x86_64_msvc 0.52.5",
745 | ]
746 |
747 | [[package]]
748 | name = "windows_aarch64_gnullvm"
749 | version = "0.48.0"
750 | source = "registry+https://github.com/rust-lang/crates.io-index"
751 | checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
752 |
753 | [[package]]
754 | name = "windows_aarch64_gnullvm"
755 | version = "0.52.5"
756 | source = "registry+https://github.com/rust-lang/crates.io-index"
757 | checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
758 |
759 | [[package]]
760 | name = "windows_aarch64_msvc"
761 | version = "0.48.0"
762 | source = "registry+https://github.com/rust-lang/crates.io-index"
763 | checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
764 |
765 | [[package]]
766 | name = "windows_aarch64_msvc"
767 | version = "0.52.5"
768 | source = "registry+https://github.com/rust-lang/crates.io-index"
769 | checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
770 |
771 | [[package]]
772 | name = "windows_i686_gnu"
773 | version = "0.48.0"
774 | source = "registry+https://github.com/rust-lang/crates.io-index"
775 | checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
776 |
777 | [[package]]
778 | name = "windows_i686_gnu"
779 | version = "0.52.5"
780 | source = "registry+https://github.com/rust-lang/crates.io-index"
781 | checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
782 |
783 | [[package]]
784 | name = "windows_i686_gnullvm"
785 | version = "0.52.5"
786 | source = "registry+https://github.com/rust-lang/crates.io-index"
787 | checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
788 |
789 | [[package]]
790 | name = "windows_i686_msvc"
791 | version = "0.48.0"
792 | source = "registry+https://github.com/rust-lang/crates.io-index"
793 | checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
794 |
795 | [[package]]
796 | name = "windows_i686_msvc"
797 | version = "0.52.5"
798 | source = "registry+https://github.com/rust-lang/crates.io-index"
799 | checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
800 |
801 | [[package]]
802 | name = "windows_x86_64_gnu"
803 | version = "0.48.0"
804 | source = "registry+https://github.com/rust-lang/crates.io-index"
805 | checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
806 |
807 | [[package]]
808 | name = "windows_x86_64_gnu"
809 | version = "0.52.5"
810 | source = "registry+https://github.com/rust-lang/crates.io-index"
811 | checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
812 |
813 | [[package]]
814 | name = "windows_x86_64_gnullvm"
815 | version = "0.48.0"
816 | source = "registry+https://github.com/rust-lang/crates.io-index"
817 | checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
818 |
819 | [[package]]
820 | name = "windows_x86_64_gnullvm"
821 | version = "0.52.5"
822 | source = "registry+https://github.com/rust-lang/crates.io-index"
823 | checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
824 |
825 | [[package]]
826 | name = "windows_x86_64_msvc"
827 | version = "0.48.0"
828 | source = "registry+https://github.com/rust-lang/crates.io-index"
829 | checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
830 |
831 | [[package]]
832 | name = "windows_x86_64_msvc"
833 | version = "0.52.5"
834 | source = "registry+https://github.com/rust-lang/crates.io-index"
835 | checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
836 |
837 | [[package]]
838 | name = "winnow"
839 | version = "0.5.0"
840 | source = "registry+https://github.com/rust-lang/crates.io-index"
841 | checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7"
842 | dependencies = [
843 | "memchr",
844 | ]
845 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cdwe"
3 | description = "cd with env vars"
4 | version = "0.3.0"
5 | edition = "2021"
6 | authors = ["synoet"]
7 | include = ["src/**/*.rs", "shells/*"]
8 | categories = ["command-line-utilities"]
9 | homepage = "https://github.com/synoet/cdwe"
10 | repository = "https://github.com/synoet/cdwe"
11 | license = "MIT"
12 | readme = "README.md"
13 | keywords = [
14 | "cli",
15 | "command",
16 | "command-line",
17 | "shell",
18 | "tool",
19 | ]
20 |
21 | [dependencies]
22 | anyhow = "1.0.72"
23 | clap = { version="4.3.12", features=["derive"] }
24 | regex = "1.10.4"
25 | serde = {version = "1.0.171", features = ["derive"]}
26 | serde_json = "1.0.117"
27 | sha2 = "0.10.8"
28 | tokio = { version = "1.38.0", features = ["tokio-macros", "rt", "full"] }
29 | toml = "0.7.6"
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # ⚡️cdwe (cd with env)
4 | A simple configurable cd wrapper that provides powerful utilities for customizing your envionment per directory. \
5 | *(For **ZSH** / **BASH** / **FISH** Shells)*
6 |
7 |
8 | [Installation](#installation) •
9 | [Usage](#usage) •
10 | [Configuration](#configuration) •
11 | [Uninstalling](#uninstalling)
12 |
13 |
14 | 
15 |
16 | ## Features
17 |
18 | - **Per Directory Environment Variables**
19 | - **Auto Load .env files in Directories**
20 | - **Auto Execute Commands in Directories**
21 | - **Per Directory Aliases**
22 | - **Works with any CD like Command**
23 |
24 | ## Installation
25 |
26 | 1. **Install binary**
27 | ```bash
28 | cargo install cdwe
29 | ```
30 |
31 | 2. **Init your shell**
32 | ```bash
33 | cdwe init zsh # zsh shells
34 | cdwe init bash # bash shells
35 | cdwe init fish # fish shells
36 | ```
37 |
38 | 3. **Reload your shell and start using!**
39 | ```bash
40 | # check that env var gets set
41 | cdwe /Users/synoet/dev/projecta
42 | echo $IS_DEBUG
43 |
44 | # check that env var gets unset
45 | cdwe ..
46 | echo $IS_DEBUG
47 | ```
48 |
49 | ## Usage
50 |
51 | ### Defining Per Directory Env Variables
52 | ---
53 |
54 | You can explicitly define environment variables in two ways:
55 | ```toml
56 | [[directory]]
57 | path = "/Users/synoet/dev/project"
58 | vars = {"IS_DEBUG" = "true", "IS_PROD" = "false"}
59 |
60 | # or
61 |
62 | [[directory]]
63 | path = "/Users/synoet/dev/project"
64 | vars = [
65 | {name="IS_DEBUG", value ="true"},
66 | {name="IS_PROD", value="false"}
67 | ]
68 | ```
69 | `path`: the path to your directory you are configuring
70 |
71 | `vars`: a map of env vars to set
72 |
73 | *By default env vars will also be loaded in subdirectories, in this example `/Users/synoet/dev/project/src` would also have `IS_DEBUG` and `IS_PROD` set*
74 |
75 | *OR*
76 |
77 |
78 | ```toml
79 | [[env_variable]]
80 | name = "IS_DEBUG"
81 | value = "true"
82 | dirs = [
83 | "/Users/synoet/dev/project1",
84 | "/Users/synoet/dev/project2"
85 | ]
86 | ```
87 | Here you can define one env var for multiple directories.
88 |
89 | `name`: Is the key of the env variable
90 |
91 | `value`: is the value of the env variable
92 |
93 | `dirs`: Is a list of directories to load this env var for
94 |
95 | ### Loading From .env files
96 | ---
97 | The directory object also takes a `load_from` field
98 | ```toml
99 | [[directory]]
100 | path = "/Users/synoet/dev/project"
101 | vars = {"IS_DEBUG" = "true", "IS_PROD" = "false"}
102 | load_from = [".env"]
103 | ```
104 | `load_from`: List of .env file names to auto load in, these should be relative to the dir defined in path.
105 |
106 | In this example we would try to load in a env file at `/Users/synoet/dev/project/.env`
107 |
108 | *Unlike per directory env vars, env files are only loaded in the exact matching directory not in subdirectories*
109 |
110 | **OR**
111 |
112 | Similarly we can define a single env file for multiple directories
113 |
114 | ```toml
115 | [[env_file]]
116 | load_from = ".env"
117 | dirs = [
118 | "/Users/synoet/dev/macro/macro-site/astro",
119 | "/Users/synoet/dev/macro/app-monorepo/packages/app"
120 | ]
121 | ```
122 |
123 | ### Defining Aliases Per Directory
124 | ---
125 | Here we can define aliases that will be set and unset as functions only in specific directories
126 |
127 | ```toml
128 | [[directory]]
129 | path = "/Users/synoet/dev/project"
130 | vars = {"IS_DEBUG" = "true", "IS_PROD" = "false"}
131 | load_from = [".env"]
132 | aliases = [
133 | { name = "build", commands = ["yarn cache clean", "yarn build", "yarn package"] }
134 | ]
135 | ```
136 |
137 | Here we define a `build` alias which will live only in `/User/synoet/dev/project/*` and all subdirectories.
138 |
139 | `aliases`: a list of aliases to define for the directory
140 |
141 | **OR**
142 | ```toml
143 | [[alias]]
144 | name = "build"
145 | commands = ["yarn cache clean", "yarn build", "yarn package"]
146 | dirs = [
147 | "/Users/synoet/dev/projecta",
148 | "/Users/synoet/dev/projectb"
149 | ]
150 | ```
151 | Here you are defining the same alias for multiple directories.
152 |
153 | ### Defining Auto Commands
154 | ---
155 | Here we can define commands that will automatically run anytime we cd into a specific directory
156 | ```toml
157 | [[directory]]
158 | path = "/Users/synoet/dev/project"
159 | vars = {"IS_DEBUG" = "true", "IS_PROD" = "false"}
160 | load_from = [".env"]
161 | aliases = [
162 | { name = "build", commands = ["yarn cache clean", "yarn build", "yarn package"] }
163 | ]
164 | run = ["git fetch -p", "ls"]
165 | ```
166 | In this case every time we enter `/Users/synoet/dev/project` cdwe will automatically run `git fetch -p` and `ls`
167 |
168 | *Auto Commands also require an exact match and don't propogate to subdirectories*
169 |
170 | **OR**
171 |
172 | ```toml
173 | [[command]]
174 | run = "git fetch -p"
175 | dirs = [
176 | "/Users/synoet/dev/cdwe",
177 | "/Users/synoet/dev/macro/macro-api"
178 | ]
179 | ```
180 |
181 | ## Configuration
182 | ### Global Configuration Options
183 | ```toml
184 | [config]
185 | # Shell (Created during cdwe init )
186 | shell = "zsh"
187 | # Custom CD Command (defaults to cd)
188 | cd_command = "z"
189 | # Show alias hints on cd
190 | alias_hints = true
191 | # Show env hints on cd
192 | env_hints = true
193 | # shoe run hints on cd
194 | run_hints = true
195 | ```
196 |
197 | ### Example Configuration
198 | ```toml
199 | [config]
200 | cd_command = "z"
201 | alias_hints = true
202 | env_hints = true
203 | command_hints = true
204 | run_hints = true
205 | shell = "zsh"
206 |
207 | # Defined a directory
208 | # Will have env var "TEST" set in this directory
209 | # Will auto run "git fetch -p" whenever you cd into this dir
210 | # Exposes the following aliases in that directory and sub dirs
211 | [[directory]]
212 | path = "/Users/synoet/dev/cdwe"
213 | vars = { "TEST" = "testing" }
214 | runs = ["git fetch -p"]
215 | aliases = [
216 | { name = "build", commands = ["cargo build --release"]},
217 | { name = "run", commands = ["cargo run"]},
218 | { name = "ci", commands = ["cargo fmt", "cargo test"]}
219 | ]
220 |
221 | # sets the "ENV_VAR" env var in the following directories
222 | [[env_variable]]
223 | name = "ENV_VAR"
224 | value = "THIS IS A TEST"
225 | dirs = [
226 | "/Users/synoet/dev/cdwe",
227 | "/Users/synoet/dev/ballast"
228 | ]
229 |
230 | # auto loads from .env file in following directories
231 | [[env_file]]
232 | load_from = ".env"
233 | dirs = [
234 | "/Users/synoet/dev/cdwe",
235 | "/Users/synoet/dev/project-api"
236 | ]
237 |
238 | # will auto run the command "git fetch -p" in the following directories
239 | [[command]]
240 | run = "git fetch -p"
241 | dirs = [
242 | "/Users/synoet/dev/cdwe",
243 | "/Users/synoet/dev/project-api"
244 | ]
245 | ```
246 |
247 | ### Using CDWE Environment Variables in the paths
248 |
249 | If you want to use something like **$HOME** or any other environment variable
250 | set in a path, you can do so by wrapping the environment variable inside of
251 | `{{}}`. Using **$HOME** as an example, you would do {{HOME}}. This can make
252 | using one cdwe.toml across many machines nice if you have different users but a
253 | similar directory structure for each user.
254 |
255 | ## Uninstalling
256 | 1. Run cdwe-remove to clean up all shell artifacts
257 | ```bash
258 | cdwe-remove #removes the `source