diff options
author | Canop <cano.petrole@gmail.com> | 2023-07-16 18:24:56 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2023-07-16 18:27:59 +0200 |
commit | bcabc0381e82f33b20f9ace1ff77241625129fb5 (patch) | |
tree | 8584fd7c786d56cc9f6a5b08a99f2b3a563f85fa | |
parent | fb154c5ac304677a264ffcbd0ae62a588effb7aa (diff) |
better --help, man page, completion scripts
Fix #45
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | Cargo.lock | 427 | ||||
-rw-r--r-- | Cargo.toml | 19 | ||||
-rw-r--r-- | build.rs | 56 | ||||
-rw-r--r-- | cli/Cargo.toml | 27 | ||||
-rw-r--r-- | cli/src/args.rs | 102 | ||||
-rw-r--r-- | cli/src/col.rs (renamed from src/col.rs) | 0 | ||||
-rw-r--r-- | cli/src/col_expr.rs (renamed from src/col_expr.rs) | 0 | ||||
-rw-r--r-- | cli/src/cols.rs (renamed from src/cols.rs) | 0 | ||||
-rw-r--r-- | cli/src/csv.rs (renamed from src/csv.rs) | 0 | ||||
-rw-r--r-- | cli/src/filter.rs (renamed from src/filter.rs) | 2 | ||||
-rw-r--r-- | cli/src/json.rs (renamed from src/json.rs) | 0 | ||||
-rw-r--r-- | cli/src/lib.rs | 101 | ||||
-rw-r--r-- | cli/src/list_cols.rs (renamed from src/list_cols.rs) | 0 | ||||
-rw-r--r-- | cli/src/normal.rs (renamed from src/normal.rs) | 0 | ||||
-rw-r--r-- | cli/src/order.rs (renamed from src/order.rs) | 0 | ||||
-rw-r--r-- | cli/src/sorting.rs (renamed from src/sorting.rs) | 6 | ||||
-rw-r--r-- | cli/src/table.rs (renamed from src/table.rs) | 0 | ||||
-rw-r--r-- | cli/src/units.rs (renamed from src/units.rs) | 15 | ||||
-rwxr-xr-x | compile-all-targets.sh | 10 | ||||
-rw-r--r-- | src/args.rs | 107 | ||||
-rw-r--r-- | src/main.rs | 84 |
22 files changed, 715 insertions, 247 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d3ba2d5..eb1d932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +<a name="v2.7.0"></a> +### v2.6.1 - 2023/07/02 +- improved `--help` +- man page generated in /build and included in downloadable archives +- completion scripts generated in /build and included in downloadable archives + <a name="v2.6.1"></a> ### v2.6.1 - 2023/07/02 - lfs renamed to dysk @@ -12,33 +12,53 @@ dependencies = [ ] [[package]] -name = "argh" -version = "0.1.9" +name = "anstream" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c375edecfd2074d5edcc31396860b6e54b6f928714d0e097b983053fac0cabe3" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ - "argh_derive", - "argh_shared", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", ] [[package]] -name = "argh_derive" -version = "0.1.9" +name = "anstyle" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa013479b80109a1bf01a039412b0f0013d716f36921226d86c6709032fb7a03" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ - "argh_shared", - "heck", - "proc-macro2", - "quote", - "syn", + "utf8parse", ] [[package]] -name = "argh_shared" -version = "0.1.9" +name = "anstyle-query" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "149f75bbec1827618262e0855a68f0f9a7f2edc13faebf33c4f16d6725edb6a9" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] [[package]] name = "autocfg" @@ -59,12 +79,102 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] +name = "clap" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap-help" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74090d11d4d740737b1020449d928ae0d91f72dc33a8c6c2f5c9b37659c5d54f" +dependencies = [ + "clap", + "termimad 0.23.1", + "terminal-light", +] + +[[package]] +name = "clap_builder" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "once_cell", + "strsim", +] + +[[package]] +name = "clap_complete" +version = "4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" +dependencies = [ + "clap", +] + +[[package]] +name = "clap_derive" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.26", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + +[[package]] +name = "clap_mangen" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f2e32b579dae093c2424a8b7e2bea09c89da01e1ce5065eb2f0a6f1cc15cc1f" +dependencies = [ + "clap", + "roff", +] + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] name = "coolor" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -117,7 +227,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.7.1", "scopeguard", ] @@ -146,7 +256,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossterm_winapi", "libc", "mio", @@ -173,16 +283,48 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dysk" -version = "2.6.1" +version = "2.7.0" +dependencies = [ + "clap", + "clap_complete", + "clap_mangen", + "dysk-cli", +] + +[[package]] +name = "dysk-cli" +version = "2.7.0" dependencies = [ - "argh", "bet", + "clap", + "clap-help", "crossterm", "file-size", "lfs-core", "serde", "serde_json", - "termimad", + "termimad 0.20.5", +] + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", ] [[package]] @@ -198,6 +340,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] name = "itoa" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -223,7 +382,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 1.0.105", ] [[package]] @@ -239,9 +398,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.138" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "lock_api" @@ -270,6 +435,15 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" @@ -287,6 +461,15 @@ dependencies = [ ] [[package]] +name = "minimad" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b136454924e4d020e55c4992e07c105b40d5c41b84662862f0e15bc0a2efef" +dependencies = [ + "once_cell", +] + +[[package]] name = "mio" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -295,14 +478,27 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.42.0", +] + +[[package]] +name = "nix" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if", + "libc", + "memoffset 0.6.5", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "parking_lot" @@ -324,23 +520,23 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "92de25114670a878b1261c79c9f8f729fb97e95bac93f6312f583c60dd6a1dfe" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "5907a1b7c277254a8b15170f6e7c97cfa60ee7872a3217663bb81151e48184bb" dependencies = [ "proc-macro2", ] @@ -351,7 +547,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -372,6 +568,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] +name = "roff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" + +[[package]] +name = "rustix" +version = "0.38.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + +[[package]] name = "ryu" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -455,10 +670,16 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 1.0.105", ] [[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] name = "syn" version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -470,6 +691,17 @@ dependencies = [ ] [[package]] +name = "syn" +version = "2.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] name = "termimad" version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -478,12 +710,38 @@ dependencies = [ "coolor", "crossbeam", "crossterm", - "minimad", + "minimad 0.9.1", "thiserror", "unicode-width", ] [[package]] +name = "termimad" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7df2ed35b86d796df56633f1bb1f0c15816134e221822d65bbc64d5265ce8d4" +dependencies = [ + "coolor", + "crossbeam", + "crossterm", + "minimad 0.12.0", + "thiserror", + "unicode-width", +] + +[[package]] +name = "terminal-light" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9077b39afb70f12391e4c1fcf46319999cfc32b45d605a668052bc4d1b4511af" +dependencies = [ + "coolor", + "crossterm", + "thiserror", + "xterm-query", +] + +[[package]] name = "thiserror" version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -500,7 +758,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.105", ] [[package]] @@ -516,6 +774,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -549,13 +813,37 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.0", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm 0.42.0", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -565,37 +853,90 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" [[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" [[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" [[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" [[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] name = "windows_x86_64_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" [[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" [[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "xterm-query" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec02abe9c7efbcb010adc0d90bc4a054653477cd4a3eb8eef5a689799c146a13" +dependencies = [ + "mio", + "nix", + "thiserror", +] @@ -1,6 +1,6 @@ [package] name = "dysk" -version = "2.6.1" +version = "2.7.0" authors = ["dystroy <denys.seguret@gmail.com>"] edition = "2021" keywords = ["linux", "filesystem", "fs", "lfs", "disk"] @@ -13,16 +13,16 @@ documentation = "https://dystroy.org/dysk" readme = "README.md" rust-version = "1.59" exclude = ["website", "dysk*.zip"] +build = "build.rs" [dependencies] -argh = "0.1.7" -bet = "1.0.0" -crossterm = "0.23.2" -file-size = "1.0.3" -lfs-core = "0.11.0" -serde = "1.0" -serde_json = "1.0" -termimad = "0.20.5" +dysk-cli = { path = "cli" } + +[build-dependencies] +clap = { version = "4.3", features = ["derive", "cargo"] } +clap_complete = "4.3" +clap_mangen = "0.2.12" +dysk-cli = { path = "cli" } [profile.release] strip = true @@ -30,4 +30,5 @@ strip = true [patch.crates-io] # minimad = { path = "../minimad" } # termimad = { path = "../termimad" } +# clap-help = { path = "../clap-help" } # lfs-core = { path = "../lfs-core" } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d5278e1 --- /dev/null +++ b/build.rs @@ -0,0 +1,56 @@ +//! This file is executed during compilation. +//! It builds shell completion scripts and the man page +//! +//! Note: to see the eprintln messages, run cargo with +//! cargo -vv build --release +use { + dysk_cli::args::Args, + clap::CommandFactory, + clap_complete::{Generator, Shell}, + std::{ + env, + ffi::OsStr, + path::PathBuf, + }, +}; + +fn write_completions_file<G: Generator + Copy, P: AsRef<OsStr>>(generator: G, out_dir: P) { + let mut args = Args::command(); + clap_complete::generate_to( + generator, + &mut args, + "dysk".to_string(), + &out_dir, + ).expect("clap complete generation failed"); +} + +/// write the shell completion scripts which will be added to +/// the release archive +fn build_completion_scripts() { + let out_dir = env::var_os("OUT_DIR").expect("out dir not set"); + write_completions_file(Shell::Bash, &out_dir); + write_completions_file(Shell::Elvish, &out_dir); + write_completions_file(Shell::Fish, &out_dir); + write_completions_file(Shell::Zsh, &out_dir); + eprintln!("completion scripts generated in {out_dir:?}"); +} + +/// generate the man page from the Clap configuration +fn build_man_page() -> std::io::Result<()> { + let out_dir = env::var_os("OUT_DIR").expect("out dir not set"); + let out_dir = PathBuf::from(out_dir); + let cmd = Args::command(); + let man = clap_mangen::Man::new(cmd); + let mut buffer: Vec<u8> = Default::default(); + man.render(&mut buffer)?; + let file_path = out_dir.join("dysk.1"); + std::fs::write(&file_path, buffer)?; + eprintln!("map page generated in {file_path:?}"); + Ok(()) +} + +fn main() -> std::io::Result<()> { + build_completion_scripts(); + build_man_page()?; + Ok(()) +} diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000..c1e7f12 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "dysk-cli" +version = "2.7.0" +authors = ["dystroy <denys.seguret@gmail.com>"] +edition = "2021" +license = "MIT" +rust-version = "1.59" + +[dependencies] +bet = "1.0.0" +clap = { version = "4.3", features = ["derive", "cargo"] } +clap-help = "0.4.0" +crossterm = "0.23.2" +file-size = "1.0.3" +lfs-core = "0.11.0" +serde = "1.0" +serde_json = "1.0" +termimad = "0.20.5" + +[profile.release] +strip = true + +[patch.crates-io] +# minimad = { path = "../minimad" } +# termimad = { path = "../termimad" } +# clap-help = { path = "../clap-help" } +# lfs-core = { path = "../lfs-core" } diff --git a/cli/src/args.rs b/cli/src/args.rs new file mode 100644 index 0000000..d7c3d92 --- /dev/null +++ b/cli/src/args.rs @@ -0,0 +1,102 @@ +use { + crate::{ + cols::Cols, + filter::Filter, + units::Units, + sorting::Sorting, + }, + clap::{Parser, ValueEnum}, + crossterm::tty::IsTty, + std::path::PathBuf, +}; + +/// List your filesystems. +/// +/// Documentation at https://dystroy.org/dysk +#[derive(Debug, Parser)] +#[command(author, about, disable_version_flag = true, version, disable_help_flag = true)] +pub struct Args { + + /// print help information + #[arg(long)] + pub help: bool, + + /// print the version + #[arg(long)] + pub version: bool, + + /// show all mount points + #[arg(short, long)] + pub all: bool, + + /// Whether to have styles and colors + #[arg(long, default_value="auto", value_name = "color")] + pub color: TriBool, + + /// fetch stats of remote volumes + #[arg(long, default_value="auto", value_name = "choice")] + pub remote_stats: TriBool, + + /// list the column names which can be used in -s, -f, or -c + #[arg(long)] + pub list_cols: bool, + + /// columns, eg `-c +inodes` or `-c id+dev+default` + #[arg(short, long, default_value = "fs+type+disk+used+use+free+size+mp", value_name = "columns")] + pub cols: Cols, + + /// filter, eg `-f '(size<35G | remote=false) & type=xfs'` + #[arg(short, long, value_name = "expr")] + pub filter: Option<Filter>, + + /// sort, eg `inodes`, `type-desc`, or `size-asc` + #[arg(short, long, default_value = "size", value_name = "sort")] + pub sort: Sorting, + + /// units: `SI` (SI norm), `binary` (1024 based), or `bytes` (raw number) + #[arg(short, long, default_value = "SI", value_name = "unit")] + pub units: Units, + + /// output as JSON + #[arg(short, long)] + pub json: bool, + + /// output as CSV + #[arg(long)] + pub csv: bool, + + /// CSV separator + #[arg(long, default_value = ",", value_name = "sep")] + pub csv_separator: char, + + /// if provided, only the device holding this path will be shown + pub path: Option<PathBuf>, +} + +/// This is an Option<bool> but I didn't find any way to configure +/// clap to parse an Option<T> as I want +#[derive(ValueEnum)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum TriBool { + Auto, + Yes, + No, +} +impl TriBool { + pub fn unwrap_or_else<F>(self, f: F) -> bool + where + F: FnOnce() -> bool + { + match self { + Self::Auto => f(), + Self::Yes => true, + Self::No => false, + } + } +} + +impl Args { + pub fn color(&self) -> bool { + self.color.unwrap_or_else(|| std::io::stdout().is_tty()) + } +} diff --git a/src/col.rs b/cli/src/col.rs index 95ac649..95ac649 100644 --- a/src/col.rs +++ b/cli/src/col.rs diff --git a/src/col_expr.rs b/cli/src/col_expr.rs index 2abf476..2abf476 100644 --- a/src/col_expr.rs +++ b/cli/src/col_expr.rs diff --git a/src/cols.rs b/cli/src/cols.rs index 349534d..349534d 100644 --- a/src/cols.rs +++ b/cli/src/cols.rs diff --git a/src/csv.rs b/cli/src/csv.rs index 2543154..2543154 100644 --- a/src/csv.rs +++ b/cli/src/csv.rs diff --git a/src/filter.rs b/cli/src/filter.rs index 85ba80a..bd0b628 100644 --- a/src/filter.rs +++ b/cli/src/filter.rs @@ -16,7 +16,7 @@ enum BoolOperator { Not, } -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct Filter { expr: BeTree<BoolOperator, ColExpr>, } diff --git a/src/json.rs b/cli/src/json.rs index 1c47281..1c47281 100644 --- a/src/json.rs +++ b/cli/src/json.rs diff --git a/cli/src/lib.rs b/cli/src/lib.rs new file mode 100644 index 0000000..df78838 --- /dev/null +++ b/cli/src/lib.rs @@ -0,0 +1,101 @@ +pub mod args; +pub mod col; +pub mod col_expr; +pub mod cols; +pub mod csv; +pub mod filter; +pub mod json; +pub mod list_cols; +pub mod normal; +pub mod order; +pub mod sorting; +pub mod table; +pub mod units; + +use { + crate::{ + args::*, + normal::*, + }, + clap::{CommandFactory, Parser}, + std::{ + fs, + os::unix::fs::MetadataExt, + }, +}; + +static INTRO: &str = " + +**dysk** displays filesystem information in a pretty table. +Complete documentation at https://dystroy.org/dysk + +"; + + +#[allow(clippy::match_like_matches_macro)] +pub fn run() { + let args = Args::parse(); + if args.version { + println!("dysk {}", env!("CARGO_PKG_VERSION")); + return; + } + if args.help { + clap_help::Printer::new(Args::command()) + .with("introduction", INTRO) + .without("author") + .print_help(); + return; + } + if args.list_cols { + list_cols::print(args.color()); + return; + } + let mut options = lfs_core::ReadOptions::default(); + options |