commit 533c5ae6375ab5a74c9013d695c8ddef1c931409 Author: SW Date: Wed Jun 17 21:33:03 2026 +0200 Initial lview implementation diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..45b1e3c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2055 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "by_address" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" + +[[package]] +name = "bytemuck" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "castaway" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cc" +version = "1.2.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad887fd958be91b5098c0248def011f4523ab786cd411be668777e55063501f" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "compact_str" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "static_assertions", +] + +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossterm" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" +dependencies = [ + "bitflags 2.13.0", + "crossterm_winapi", + "derive_more", + "document-features", + "mio", + "parking_lot", + "rustix", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "csscolorparser" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" +dependencies = [ + "lab", + "phf", +] + +[[package]] +name = "darling" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.118", +] + +[[package]] +name = "darling_macro" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "deltae" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" + +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.118", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "either" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "euclid" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + +[[package]] +name = "fast-srgb8" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1" + +[[package]] +name = "filedescriptor" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d" +dependencies = [ + "libc", + "thiserror 1.0.69", + "winapi", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "finl_unicode" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9844ddc3a6e533d62bba727eb6c28b5d360921d5175e9ff0f1e621a5c590a4d5" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "fuzzy-matcher" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" +dependencies = [ + "thread_local", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "indoc" +version = "2.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" +dependencies = [ + "rustversion", +] + +[[package]] +name = "instability" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb2d60ef19920a3a9193c3e371f726ec1dafc045dac788d0fb3704272458971" +dependencies = [ + "darling", + "indoc", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d04c30968dffe80775bd4d7fb676131cd04a1fb46d2686dbffbaec2d9dfd31" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "kasuari" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde5057d6143cc94e861d90f591b9303d6716c6b9602309150bd068853c10899" +dependencies = [ + "hashbrown 0.16.1", + "portable-atomic", + "thiserror 2.0.18", +] + +[[package]] +name = "lab" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" +dependencies = [ + "libc", +] + +[[package]] +name = "line-clipping" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f50e8f47623268b5407192d26876c4d7f89d686ca130fdc53bced4814cd29f8" +dependencies = [ + "bitflags 2.13.0", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litrs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" + +[[package]] +name = "lru" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9" +dependencies = [ + "hashbrown 0.17.1", +] + +[[package]] +name = "lview" +version = "0.1.0" +dependencies = [ + "chrono", + "clap", + "crossterm", + "directories", + "fuzzy-matcher", + "ratatui", + "regex", + "serde", + "tokio", + "toml", +] + +[[package]] +name = "mac_address" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303" +dependencies = [ + "nix", + "winapi", +] + +[[package]] +name = "memchr" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" + +[[package]] +name = "memmem" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys", +] + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.13.0", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] + +[[package]] +name = "palette" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6" +dependencies = [ + "approx", + "fast-srgb8", + "libm", + "palette_derive", +] + +[[package]] +name = "palette_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5030daf005bface118c096f510ffb781fc28f9ab6a32ab224d8631be6851d30" +dependencies = [ + "by_address", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pest" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" +dependencies = [ + "memchr", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "pest_meta" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" +dependencies = [ + "pest", + "sha2", +] + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "ratatui" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1695748e3a735b34968c887ceea5a380b43545903868ae8f5b666593100f6b68" +dependencies = [ + "instability", + "ratatui-core", + "ratatui-crossterm", + "ratatui-macros", + "ratatui-termwiz", + "ratatui-widgets", + "serde", +] + +[[package]] +name = "ratatui-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3603f354bba8c595fa47860e60142d7372b7210c27044c6a7d0e1a4336b44" +dependencies = [ + "bitflags 2.13.0", + "compact_str", + "critical-section", + "hashbrown 0.17.1", + "indoc", + "itertools", + "kasuari", + "lru", + "palette", + "serde", + "strum", + "thiserror 2.0.18", + "unicode-segmentation", + "unicode-truncate", + "unicode-width", +] + +[[package]] +name = "ratatui-crossterm" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2867bedcbd6a690ca4f8672a687b730ec07660c79844517b084311b529980c" +dependencies = [ + "cfg-if", + "crossterm", + "instability", + "ratatui-core", +] + +[[package]] +name = "ratatui-macros" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80fac59720679490d89d200df411faa249be728681adcabed3d047ae72c48f1d" +dependencies = [ + "ratatui-core", + "ratatui-widgets", +] + +[[package]] +name = "ratatui-termwiz" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "386b8ff8f74ed749509391c56d549761a2fcdb408e1f42e467286bcb7dac8967" +dependencies = [ + "ratatui-core", + "termwiz", +] + +[[package]] +name = "ratatui-widgets" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef4f17dd7ac3abf5adc2b920a03c61eee4bfe6a88fa5191936895525371d79c" +dependencies = [ + "bitflags 2.13.0", + "hashbrown 0.17.1", + "indoc", + "instability", + "itertools", + "line-clipping", + "ratatui-core", + "serde", + "strum", + "time", + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.0", +] + +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom 0.2.17", + "libredox", + "thiserror 2.0.18", +] + +[[package]] +name = "regex" +version = "1.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags 2.13.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "siphasher" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "terminfo" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ea810f0692f9f51b382fff5893887bb4580f5fa246fde546e0b13e7fcee662" +dependencies = [ + "fnv", + "nom", + "phf", + "phf_codegen", +] + +[[package]] +name = "termios" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" +dependencies = [ + "libc", +] + +[[package]] +name = "termwiz" +version = "0.23.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4676b37242ccbd1aabf56edb093a4827dc49086c0ffd764a5705899e0f35f8f7" +dependencies = [ + "anyhow", + "base64", + "bitflags 2.13.0", + "fancy-regex", + "filedescriptor", + "finl_unicode", + "fixedbitset", + "hex", + "lazy_static", + "libc", + "log", + "memmem", + "nix", + "num-derive", + "num-traits", + "ordered-float", + "pest", + "pest_derive", + "phf", + "sha2", + "signal-hook", + "siphasher", + "terminfo", + "termios", + "thiserror 1.0.69", + "ucd-trie", + "unicode-segmentation", + "vtparse", + "wezterm-bidi", + "wezterm-blob-leases", + "wezterm-color-types", + "wezterm-dynamic", + "wezterm-input-types", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "time" +version = "0.3.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711a53c2d47bbd818258c498c8dbfe186a2526c631495cfe7e078567f86b8469" +dependencies = [ + "deranged", + "libc", + "num-conv", + "num_threads", + "powerfmt", + "serde_core", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "tokio" +version = "1.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-truncate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5" +dependencies = [ + "itertools", + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.23.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "144d6b123cef80b301b8f72a9e2ca4370ddec21950d0a103dd22c437006d2db7" +dependencies = [ + "atomic", + "getrandom 0.4.3", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vtparse" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d9b2acfb050df409c972a37d3b8e08cdea3bddb0c09db9d53137e504cfabed0" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ddb3f79143bced6de84270411622a2699cee572fc0875aeaf1e7867cf9fca1a" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e21a184b13fb19e157296e2c46056aec9092264fab83e4ba59e68c61b323c3d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fecefd9c35bd935a20fc3fc344b5f29138961e4f47fb03297d88f2587afb5ebd" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.118", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23939e44bb9a5d7576fa2b563dc2e136628f1224e88a8deed09e04858b77871f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wezterm-bidi" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0a6e355560527dd2d1cf7890652f4f09bb3433b6aadade4c9b5ed76de5f3ec" +dependencies = [ + "log", + "wezterm-dynamic", +] + +[[package]] +name = "wezterm-blob-leases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7" +dependencies = [ + "getrandom 0.3.4", + "mac_address", + "sha2", + "thiserror 1.0.69", + "uuid", +] + +[[package]] +name = "wezterm-color-types" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de81ef35c9010270d63772bebef2f2d6d1f2d20a983d27505ac850b8c4b4296" +dependencies = [ + "csscolorparser", + "deltae", + "lazy_static", + "wezterm-dynamic", +] + +[[package]] +name = "wezterm-dynamic" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f2ab60e120fd6eaa68d9567f3226e876684639d22a4219b313ff69ec0ccd5ac" +dependencies = [ + "log", + "ordered-float", + "strsim", + "thiserror 1.0.69", + "wezterm-dynamic-derive", +] + +[[package]] +name = "wezterm-dynamic-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c0cf2d539c645b448eaffec9ec494b8b19bd5077d9e58cb1ae7efece8d575b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "wezterm-input-types" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e" +dependencies = [ + "bitflags 1.3.2", + "euclid", + "lazy_static", + "serde", + "wezterm-dynamic", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +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" + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "winnow" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b07020d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "lview" +version = "0.1.0" +edition = "2024" +authors = ["janvete"] +description = "TUI for viewing remote logs over SSH" +license = "MIT" +repository = "https://github.com/janvete/lview" +homepage = "https://github.com/janvete/lview" +keywords = ["cli", "tui", "ssh", "logs", "docker"] +categories = ["command-line-utilities"] + +[dependencies] +chrono = "0.4.45" +clap = { version = "4.6.1", features = ["derive"] } +crossterm = "0.29.0" +directories = "6.0.0" +fuzzy-matcher = "0.3.7" +ratatui = "0.30.1" +regex = "1.11.1" +serde = { version = "1.0.217", features = ["derive"] } +tokio = { version = "1.43.0", features = ["rt-multi-thread", "process", "io-util", "sync", "time", "macros"] } +toml = "0.8.20" diff --git a/README.md b/README.md new file mode 100644 index 0000000..458b056 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# lview + +TUI pro prohlížení logů na vzdálených Linux strojích přes SSH. Automaticky detekuje systémové logy, Docker kontejnery, `/opt` aplikace a systemd journal. + +## Instalace + +### macOS (Homebrew) + +```bash +brew tap janvete/tools +brew install lview +``` + +### Ze zdroje + +```bash +cargo install --git https://github.com/janvete/lview +``` + +## Použití + +```bash +lview ssh -p22 root@192.168.53.3 +``` + +Všechny argumenty za `ssh` jsou předány přímo systémovému `ssh` příkazu, takže se použije vaše `~/.ssh/config`, SSH agent a klíče. + +## Ovládání + +### Výběr logu + +| Klávesa | Akce | +|---------|------| +| `j` / `k` nebo `↓` / `↑` | pohyb v seznamu | +| `Enter` | otevřít vybraný log | +| `/` | fuzzy filtrování seznamu logů | +| `r` | znovu načíst seznam logů | +| `q` | ukončit | + +### Prohlížeč logu + +| Klávesa | Akce | +|---------|------| +| `j` / `k` nebo `↓` / `↑` | scroll | +| `Ctrl+d` / `Ctrl+u` | scroll o 10 řádků | +| `g` / `G` | začátek / konec | +| `l` nebo `mezerník` | zapnout/vypnout živý náhled | +| `/` | vyhledávání v logu (regex, case-insensitive) | +| `n` / `N` | další / předchozí výskyt | +| `s` | uložit aktuální buffer do `/tmp` | +| `q` nebo `Esc` | zpět do výběru | + +## Konfigurace + +Vytvořte `~/.config/lview/config.toml`: + +```toml +ssh_command = "ssh" +max_log_lines = 10000 +discovery_timeout = 10 +extra_paths = ["/custom/logs"] +``` + +## License + +MIT diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..0d4b0fc --- /dev/null +++ b/src/app.rs @@ -0,0 +1,358 @@ +use std::collections::VecDeque; + +use fuzzy_matcher::skim::SkimMatcherV2; +use fuzzy_matcher::FuzzyMatcher; +use tokio::sync::mpsc::UnboundedReceiver; + +use crate::config::Config; +use crate::discovery::{discover_logs, DiscoveryResult, LogSource}; +use crate::log_stream::start_stream; +use crate::search::SearchState; +use crate::ssh::SshSession; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Screen { + Picker, + Viewer, + Search, + PickerSearch, +} + +#[derive(Debug)] +pub struct LogViewer { + pub source: LogSource, + pub buffer: VecDeque, + pub scroll: usize, + pub live: bool, + pub receiver: UnboundedReceiver, + pub max_lines: usize, + pub search: SearchState, + pub search_cursor: Option, +} + +impl LogViewer { + pub fn new(source: LogSource, receiver: UnboundedReceiver, max_lines: usize) -> Self { + Self { + source, + buffer: VecDeque::with_capacity(max_lines), + scroll: 0, + live: true, + receiver, + max_lines, + search: SearchState::default(), + search_cursor: None, + } + } + + pub fn visible_lines(&self) -> Vec<&String> { + self.buffer.iter().filter(|l| self.search.matches(l)).collect() + } + + pub fn push_line(&mut self, line: String) { + if self.buffer.len() >= self.max_lines { + self.buffer.pop_front(); + if self.scroll > 0 { + self.scroll = self.scroll.saturating_sub(1); + } + } + self.buffer.push_back(line); + if self.live { + self.scroll_to_bottom(); + } + } + + pub fn scroll_down(&mut self, n: usize) { + let max = self.buffer.len().saturating_sub(1); + self.scroll = (self.scroll + n).min(max); + self.live = false; + } + + pub fn scroll_up(&mut self, n: usize) { + self.scroll = self.scroll.saturating_sub(n); + if self.scroll < self.buffer.len().saturating_sub(1) { + self.live = false; + } + } + + pub fn scroll_to_bottom(&mut self) { + self.scroll = self.buffer.len().saturating_sub(1); + } + + pub fn scroll_to_top(&mut self) { + self.scroll = 0; + self.live = false; + } + + pub fn toggle_live(&mut self) { + self.live = !self.live; + if self.live { + self.scroll_to_bottom(); + } + } + + pub fn set_search(&mut self, query: String) { + self.search.query = query; + self.search_cursor = None; + if !self.search.query.is_empty() + && let Some(idx) = self.search.next_match(self.buffer.make_contiguous(), self.scroll) + { + self.scroll = idx; + self.search_cursor = Some(idx); + self.live = false; + } + } + + pub fn next_search_result(&mut self) { + let lines: Vec = self.buffer.iter().cloned().collect(); + if let Some(idx) = self.search.next_match(&lines, self.scroll) { + self.scroll = idx; + self.search_cursor = Some(idx); + self.live = false; + } + } + + pub fn prev_search_result(&mut self) { + let lines: Vec = self.buffer.iter().cloned().collect(); + if let Some(idx) = self.search.prev_match(&lines, self.scroll) { + self.scroll = idx; + self.search_cursor = Some(idx); + self.live = false; + } + } +} + +pub struct App { + pub session: SshSession, + pub config: Config, + pub logs: Vec, + pub filtered_indices: Vec, + pub selected_index: usize, + pub screen: Screen, + pub viewer: Option, + pub picker_filter: String, + pub message: Option, + pub loading: bool, + pub discovery_errors: Vec, + matcher: SkimMatcherV2, +} + +impl App { + pub fn new(session: SshSession, config: Config) -> Self { + Self { + session, + config, + logs: Vec::new(), + filtered_indices: Vec::new(), + selected_index: 0, + screen: Screen::Picker, + viewer: None, + picker_filter: String::new(), + message: Some("Press 'r' to load logs".into()), + loading: false, + discovery_errors: Vec::new(), + matcher: SkimMatcherV2::default(), + } + } + + pub async fn discover(&mut self) { + self.loading = true; + self.message = Some("Loading logs...".into()); + let result = discover_logs( + &self.session, + &self.config.extra_paths, + self.config.discovery_timeout, + ) + .await; + self.apply_discovery(result); + self.loading = false; + } + + fn apply_discovery(&mut self, result: DiscoveryResult) { + self.logs = result.sources; + self.discovery_errors = result.errors; + self.apply_picker_filter(); + self.selected_index = 0; + if self.logs.is_empty() { + self.message = Some("No logs found.".into()); + } else { + self.message = Some(format!("Found {} logs", self.logs.len())); + } + } + + pub fn apply_picker_filter(&mut self) { + if self.picker_filter.is_empty() { + self.filtered_indices = (0..self.logs.len()).collect(); + } else { + let mut scored: Vec<(i64, usize)> = self + .logs + .iter() + .enumerate() + .filter_map(|(i, log)| { + self.matcher + .fuzzy_match(&log.to_string(), &self.picker_filter) + .map(|score| (score, i)) + }) + .collect(); + scored.sort_by_key(|b| std::cmp::Reverse(b.0)); + self.filtered_indices = scored.into_iter().map(|(_, i)| i).collect(); + } + self.selected_index = self + .selected_index + .min(self.filtered_indices.len().saturating_sub(1)); + } + + pub fn selected_log(&self) -> Option<&LogSource> { + self.filtered_indices + .get(self.selected_index) + .and_then(|&i| self.logs.get(i)) + } + + pub fn next_log(&mut self) { + if !self.filtered_indices.is_empty() { + self.selected_index = (self.selected_index + 1) % self.filtered_indices.len(); + } + } + + pub fn previous_log(&mut self) { + if !self.filtered_indices.is_empty() { + self.selected_index = self + .selected_index + .checked_sub(1) + .unwrap_or(self.filtered_indices.len() - 1); + } + } + + pub fn open_selected_log(&mut self) -> std::io::Result<()> { + let Some(source) = self.selected_log().cloned() else { + return Ok(()); + }; + let rx = start_stream(&self.session, &source, 1000)?; + self.viewer = Some(LogViewer::new(source, rx, self.config.max_log_lines)); + self.screen = Screen::Viewer; + self.message = None; + Ok(()) + } + + pub fn close_viewer(&mut self) { + self.viewer = None; + self.screen = Screen::Picker; + self.message = None; + } + + pub fn update_stream(&mut self) { + if let Some(viewer) = &mut self.viewer { + while let Ok(line) = viewer.receiver.try_recv() { + viewer.push_line(line); + } + } + } + + pub fn enter_search(&mut self) { + self.screen = match self.screen { + Screen::Picker => Screen::PickerSearch, + Screen::Viewer => Screen::Search, + _ => self.screen, + }; + } + + pub fn exit_search(&mut self) { + self.screen = match self.screen { + Screen::PickerSearch => Screen::Picker, + Screen::Search => Screen::Viewer, + _ => self.screen, + }; + if let Some(v) = &mut self.viewer { + v.search = SearchState::default(); + v.search_cursor = None; + } + } + + pub fn confirm_search(&mut self) { + self.screen = match self.screen { + Screen::PickerSearch => Screen::Picker, + Screen::Search => Screen::Viewer, + _ => self.screen, + }; + } + + pub fn current_filter_query(&self) -> &str { + match self.screen { + Screen::PickerSearch => &self.picker_filter, + Screen::Search => self.viewer.as_ref().map(|v| v.search.query.as_str()).unwrap_or(""), + _ => "", + } + } + + pub fn current_filter_query_mut(&mut self) -> Option<&mut String> { + match self.screen { + Screen::PickerSearch => Some(&mut self.picker_filter), + Screen::Search => self.viewer.as_mut().map(|v| &mut v.search.query), + _ => None, + } + } + + pub fn apply_current_filter(&mut self) { + if self.screen == Screen::PickerSearch { + self.apply_picker_filter(); + } else if let Some(v) = &mut self.viewer { + let query = v.search.query.clone(); + v.set_search(query); + } + } + + pub fn save_viewer_buffer(&self) -> Option { + let viewer = self.viewer.as_ref()?; + let name = format!( + "lview-{}-{}", + viewer.source.to_string().replace(['/', ' ', ':'], "_"), + chrono::Local::now().format("%Y%m%d-%H%M%S") + ); + let path = std::env::temp_dir().join(name); + let content: String = viewer + .buffer + .iter() + .cloned() + .collect::>() + .join("\n"); + std::fs::write(&path, content).ok()?; + Some(path.to_string_lossy().to_string()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_log_viewer_push_and_scroll() { + let (_tx, rx) = tokio::sync::mpsc::unbounded_channel(); + let mut v = LogViewer::new( + LogSource::File { path: "/tmp/test.log".into() }, + rx, + 100, + ); + for i in 0..5 { + v.push_line(format!("line {}", i)); + } + assert_eq!(v.buffer.len(), 5); + assert_eq!(v.scroll, 4); + v.scroll_up(2); + assert_eq!(v.scroll, 2); + v.toggle_live(); + assert!(v.live); + assert_eq!(v.scroll, 4); + } + + #[test] + fn test_app_filter() { + let session = SshSession::new("ssh".into(), crate::ssh::SshTarget { args: vec!["host".into()] }); + let mut app = App::new(session, Config::default()); + app.logs = vec![ + LogSource::File { path: "/var/log/syslog".into() }, + LogSource::File { path: "/opt/app/app.log".into() }, + ]; + app.picker_filter = "syslog".into(); + app.apply_picker_filter(); + assert_eq!(app.filtered_indices, vec![0]); + } +} diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..34b9a20 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,78 @@ +use std::fs; +use std::path::PathBuf; + +use directories::ProjectDirs; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Config { + #[serde(default = "default_ssh_command")] + pub ssh_command: String, + #[serde(default = "default_max_log_lines")] + pub max_log_lines: usize, + #[serde(default = "default_discovery_timeout")] + pub discovery_timeout: u64, + #[serde(default)] + pub extra_paths: Vec, +} + +impl Default for Config { + fn default() -> Self { + Self { + ssh_command: default_ssh_command(), + max_log_lines: default_max_log_lines(), + discovery_timeout: default_discovery_timeout(), + extra_paths: Vec::new(), + } + } +} + +impl Config { + pub fn load() -> Self { + let path = Self::config_path(); + if path.exists() { + match fs::read_to_string(&path) { + Ok(content) => match toml::from_str(&content) { + Ok(config) => config, + Err(e) => { + eprintln!( + "Warning: failed to parse config {}: {}. Using defaults.", + path.display(), + e + ); + Self::default() + } + }, + Err(e) => { + eprintln!( + "Warning: failed to read config {}: {}. Using defaults.", + path.display(), + e + ); + Self::default() + } + } + } else { + Self::default() + } + } + + pub fn config_path() -> PathBuf { + match ProjectDirs::from("com", "janvete", "lview") { + Some(dirs) => dirs.config_dir().join("config.toml"), + None => PathBuf::from(".").join("lview-config.toml"), + } + } +} + +fn default_ssh_command() -> String { + "ssh".to_string() +} + +fn default_max_log_lines() -> usize { + 10_000 +} + +fn default_discovery_timeout() -> u64 { + 10 +} diff --git a/src/discovery.rs b/src/discovery.rs new file mode 100644 index 0000000..977edc3 --- /dev/null +++ b/src/discovery.rs @@ -0,0 +1,189 @@ +use std::fmt; + +use crate::ssh::SshSession; + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum LogSource { + File { path: String }, + Docker { container: String, image: String }, + Journal { unit: String }, +} + +impl fmt::Display for LogSource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + LogSource::File { path } => write!(f, "{}", path), + LogSource::Docker { container, image } => write!(f, "{} ({})", container, image), + LogSource::Journal { unit } => write!(f, "{}", unit), + } + } +} + +impl LogSource { + pub fn category(&self) -> &'static str { + match self { + LogSource::File { path } => { + if path.starts_with("/opt/") { + "opt" + } else if path.starts_with("/var/log/") { + "system" + } else { + "other" + } + } + LogSource::Docker { .. } => "docker", + LogSource::Journal { .. } => "journal", + } + } + + pub fn sort_key(&self) -> String { + format!("{}:{}", self.category(), self) + } +} + +pub struct DiscoveryResult { + pub sources: Vec, + pub errors: Vec, +} + +pub async fn discover_logs(session: &SshSession, extra_paths: &[String], timeout_secs: u64) -> DiscoveryResult { + let mut result = DiscoveryResult { + sources: Vec::new(), + errors: Vec::new(), + }; + + let system = discover_system_logs(session, timeout_secs); + let docker = discover_docker(session, timeout_secs); + let opt = discover_opt_logs(session, extra_paths, timeout_secs); + let journal = discover_journal(session, timeout_secs); + + let (system, docker, opt, journal) = tokio::join!(system, docker, opt, journal); + + match system { + Ok(items) => result.sources.extend(items), + Err(e) => result.errors.push(format!("system logs: {}", e)), + } + match docker { + Ok(items) => result.sources.extend(items), + Err(e) => result.errors.push(format!("docker: {}", e)), + } + match opt { + Ok(items) => result.sources.extend(items), + Err(e) => result.errors.push(format!("/opt logs: {}", e)), + } + match journal { + Ok(items) => result.sources.extend(items), + Err(e) => result.errors.push(format!("journal: {}", e)), + } + + result.sources.sort_by_key(|a| a.sort_key()); + result.sources.dedup(); + result +} + +async fn discover_system_logs(session: &SshSession, timeout_secs: u64) -> Result, String> { + let cmd = "find /var/log -maxdepth 3 -type f 2>/dev/null | head -n 200"; + let out = session.exec(cmd, timeout_secs).await.map_err(|e| e.to_string())?; + let text = String::from_utf8_lossy(&out); + let mut items = Vec::new(); + for line in text.lines() { + let path = line.trim(); + if !path.is_empty() { + items.push(LogSource::File { path: path.to_string() }); + } + } + Ok(items) +} + +async fn discover_docker(session: &SshSession, timeout_secs: u64) -> Result, String> { + let cmd = "docker ps --format '{{.Names}}\\t{{.Image}}' 2>/dev/null | head -n 200"; + let out = session.exec(cmd, timeout_secs).await.map_err(|e| e.to_string())?; + let text = String::from_utf8_lossy(&out); + let mut items = Vec::new(); + for line in text.lines() { + let parts: Vec<&str> = line.split('\t').collect(); + if parts.len() >= 2 { + items.push(LogSource::Docker { + container: parts[0].trim().to_string(), + image: parts[1].trim().to_string(), + }); + } + } + Ok(items) +} + +async fn discover_opt_logs( + session: &SshSession, + extra_paths: &[String], + timeout_secs: u64, +) -> Result, String> { + let mut paths = vec!["/opt".to_string()]; + paths.extend(extra_paths.iter().cloned()); + let paths_str = paths + .iter() + .map(|p| shell_escape(p)) + .collect::>() + .join(" "); + + let cmd = format!( + "find {} -maxdepth 3 -type f \\( -name '*.log' -o -name 'docker-compose.yml' -o -name 'compose.yml' \\) 2>/dev/null | head -n 200", + paths_str + ); + let out = session.exec(&cmd, timeout_secs).await.map_err(|e| e.to_string())?; + let text = String::from_utf8_lossy(&out); + let mut items = Vec::new(); + for line in text.lines() { + let path = line.trim(); + if !path.is_empty() { + items.push(LogSource::File { path: path.to_string() }); + } + } + Ok(items) +} + +async fn discover_journal(session: &SshSession, timeout_secs: u64) -> Result, String> { + let cmd = "systemctl list-units --type=service --state=running --no-pager --plain 2>/dev/null | tail -n +2 | head -n 100"; + let out = session.exec(cmd, timeout_secs).await.map_err(|e| e.to_string())?; + let text = String::from_utf8_lossy(&out); + let mut items = Vec::new(); + for line in text.lines() { + let parts: Vec<&str> = line.split_whitespace().collect(); + if let Some(unit) = parts.first() + && unit.ends_with(".service") + { + items.push(LogSource::Journal { + unit: unit.to_string(), + }); + } + } + Ok(items) +} + +fn shell_escape(s: &str) -> String { + if s.contains(' ') || s.contains('"') || s.contains('\\') || s.contains('\'') { + format!("'{}'", s.replace('\'', "'\"'\"'")) + } else { + s.to_string() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_categories() { + assert_eq!( + LogSource::File { path: "/var/log/syslog".into() }.category(), + "system" + ); + assert_eq!( + LogSource::File { path: "/opt/app/app.log".into() }.category(), + "opt" + ); + assert_eq!( + LogSource::Docker { container: "c".into(), image: "i".into() }.category(), + "docker" + ); + } +} diff --git a/src/events.rs b/src/events.rs new file mode 100644 index 0000000..573dff1 --- /dev/null +++ b/src/events.rs @@ -0,0 +1,121 @@ +use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; + +use crate::app::{App, Screen}; + +/// Returns true if the app should keep running. +pub fn handle_event(app: &mut App, event: Event) -> bool { + match event { + Event::Key(key) if key.kind == KeyEventKind::Press => handle_key(app, key), + _ => true, + } +} + +fn handle_key(app: &mut App, key: KeyEvent) -> bool { + // Global quit + if key.code == KeyCode::Char('q') + && !matches!(app.screen, Screen::Search | Screen::PickerSearch) + { + return false; + } + + match app.screen { + Screen::Picker => handle_picker(app, key), + Screen::Viewer => handle_viewer(app, key), + Screen::Search => handle_search(app, key), + Screen::PickerSearch => handle_picker_search(app, key), + } +} + +fn handle_picker(app: &mut App, key: KeyEvent) -> bool { + match key.code { + KeyCode::Char('q') | KeyCode::Char('Q') => return false, + KeyCode::Char('j') | KeyCode::Down => app.next_log(), + KeyCode::Char('k') | KeyCode::Up => app.previous_log(), + KeyCode::Enter => { + if let Err(e) = app.open_selected_log() { + app.message = Some(format!("Failed to open log: {}", e)); + } + } + KeyCode::Char('/') => app.enter_search(), + KeyCode::Char('r') => { + // Async discovery is triggered from main loop + app.loading = true; + } + _ => {} + } + true +} + +fn handle_viewer(app: &mut App, key: KeyEvent) -> bool { + let Some(viewer) = app.viewer.as_mut() else { + app.screen = Screen::Picker; + return true; + }; + + match key.code { + KeyCode::Char('q') | KeyCode::Char('Q') | KeyCode::Esc => app.close_viewer(), + KeyCode::Char('j') | KeyCode::Down => viewer.scroll_down(1), + KeyCode::Char('k') | KeyCode::Up => viewer.scroll_up(1), + KeyCode::Char('d') if key.modifiers.contains(KeyModifiers::CONTROL) => viewer.scroll_down(10), + KeyCode::Char('u') if key.modifiers.contains(KeyModifiers::CONTROL) => viewer.scroll_up(10), + KeyCode::Char('g') => viewer.scroll_to_top(), + KeyCode::Char('G') => viewer.scroll_to_bottom(), + KeyCode::Char('l') | KeyCode::Char(' ') => viewer.toggle_live(), + KeyCode::Char('/') => app.enter_search(), + KeyCode::Char('n') => { + viewer.next_search_result(); + } + KeyCode::Char('N') => { + viewer.prev_search_result(); + } + KeyCode::Char('s') => { + if let Some(path) = app.save_viewer_buffer() { + app.message = Some(format!("Saved to {}", path)); + } + } + _ => {} + } + true +} + +fn handle_search(app: &mut App, key: KeyEvent) -> bool { + match key.code { + KeyCode::Esc => app.exit_search(), + KeyCode::Enter => app.confirm_search(), + KeyCode::Backspace => { + if let Some(query) = app.current_filter_query_mut() { + query.pop(); + app.apply_current_filter(); + } + } + KeyCode::Char(c) => { + if let Some(query) = app.current_filter_query_mut() { + query.push(c); + app.apply_current_filter(); + } + } + _ => {} + } + true +} + +fn handle_picker_search(app: &mut App, key: KeyEvent) -> bool { + match key.code { + KeyCode::Esc => app.exit_search(), + KeyCode::Enter => app.confirm_search(), + KeyCode::Backspace => { + if let Some(query) = app.current_filter_query_mut() { + query.pop(); + app.apply_current_filter(); + } + } + KeyCode::Char(c) => { + if let Some(query) = app.current_filter_query_mut() { + query.push(c); + app.apply_current_filter(); + } + } + _ => {} + } + true +} diff --git a/src/log_stream.rs b/src/log_stream.rs new file mode 100644 index 0000000..039cf02 --- /dev/null +++ b/src/log_stream.rs @@ -0,0 +1,51 @@ +use crate::discovery::LogSource; +use crate::ssh::SshSession; + +pub fn start_stream(session: &SshSession, source: &LogSource, tail_lines: usize) -> std::io::Result> { + let remote_command = build_command(source, tail_lines); + session.stream_lines(&remote_command) +} + +fn build_command(source: &LogSource, tail_lines: usize) -> String { + match source { + LogSource::File { path } => { + format!("tail -n {} -f {}", tail_lines, shell_escape(path)) + } + LogSource::Docker { container, .. } => { + format!( + "docker logs -f --tail {} {}", + tail_lines, + shell_escape(container) + ) + } + LogSource::Journal { unit } => { + format!( + "journalctl -u {} -f -n {} --no-pager", + shell_escape(unit), + tail_lines + ) + } + } +} + +fn shell_escape(s: &str) -> String { + if s.contains(' ') || s.contains('"') || s.contains('\\') || s.contains('\'') { + format!("'{}'", s.replace('\'', "'\"'\"'")) + } else { + s.to_string() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_build_command() { + let s = LogSource::File { path: "/var/log/syslog".into() }; + assert!(build_command(&s, 100).contains("tail -n 100 -f /var/log/syslog")); + + let d = LogSource::Docker { container: "web".into(), image: "nginx".into() }; + assert!(build_command(&d, 50).contains("docker logs -f --tail 50 web")); + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..05f4264 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,116 @@ +mod app; +mod config; +mod discovery; +mod events; +mod log_stream; +mod search; +mod ssh; +mod ui; + +use std::io; +use std::time::Duration; + +use clap::{Parser, Subcommand}; +use crossterm::{ + event::{DisableMouseCapture, EnableMouseCapture, poll, read}, + execute, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, +}; +use ratatui::{ + backend::{Backend, CrosstermBackend}, + Terminal, +}; +use tokio::runtime::Runtime; + +use crate::app::App; +use crate::config::Config; +use crate::ssh::{SshSession, SshTarget}; + +#[derive(Parser, Debug)] +#[command(name = "lview")] +#[command(about = "TUI for viewing remote logs over SSH")] +#[command(version)] +struct Args { + #[command(subcommand)] + command: Option, +} + +#[derive(Subcommand, Debug)] +enum Command { + /// Connect via SSH and browse logs. + /// + /// All arguments after `ssh` are passed directly to the system ssh command, + /// so your ~/.ssh/config, keys and agent settings are honored. + Ssh { + /// Arguments passed to ssh (e.g. -p22 root@host). + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, +} + +fn main() -> io::Result<()> { + let args = Args::parse(); + let command = args.command.unwrap_or_else(|| { + eprintln!("Usage: lview ssh [ssh-options] [user@]host"); + std::process::exit(1); + }); + + let Command::Ssh { args: ssh_args } = command; + if ssh_args.is_empty() { + eprintln!("Error: missing SSH target."); + eprintln!("Example: lview ssh -p22 root@192.168.53.3"); + std::process::exit(1); + } + + let config = Config::load(); + let target = SshTarget { args: ssh_args }; + let session = SshSession::new(config.ssh_command.clone(), target); + + let rt = Runtime::new()?; + + // Run discovery before entering TUI + let mut app = App::new(session, config); + rt.block_on(app.discover()); + + enable_raw_mode()?; + let mut stdout = io::stdout(); + execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?; + let backend = CrosstermBackend::new(stdout); + let mut terminal = Terminal::new(backend)?; + + let result = run_app(&mut terminal, app, &rt); + + disable_raw_mode()?; + execute!( + terminal.backend_mut(), + LeaveAlternateScreen, + DisableMouseCapture + )?; + terminal.show_cursor()?; + + result +} + +fn run_app(terminal: &mut Terminal, mut app: App, rt: &Runtime) -> io::Result<()> +where + io::Error: From<::Error>, +{ + let tick_rate = Duration::from_millis(100); + + loop { + app.update_stream(); + + if app.loading { + rt.block_on(app.discover()); + } + + terminal.draw(|f| ui::draw(f, &app))?; + + if poll(tick_rate)? { + let event = read()?; + if !events::handle_event(&mut app, event) { + return Ok(()); + } + } + } +} diff --git a/src/search.rs b/src/search.rs new file mode 100644 index 0000000..7455696 --- /dev/null +++ b/src/search.rs @@ -0,0 +1,111 @@ +use regex::Regex; + +#[derive(Debug, Clone)] +pub struct SearchState { + pub query: String, + pub is_regex: bool, +} + +impl Default for SearchState { + fn default() -> Self { + Self { + query: String::new(), + is_regex: true, + } + } +} + +impl SearchState { + pub fn compile(&self) -> Option { + if self.query.is_empty() { + return None; + } + let pattern = if self.is_regex { + self.query.clone() + } else { + regex::escape(&self.query) + }; + regex::RegexBuilder::new(&pattern) + .case_insensitive(true) + .build() + .ok() + } + + pub fn matches(&self, line: &str) -> bool { + self.compile().map(|re| re.is_match(line)).unwrap_or(true) + } + + pub fn next_match(&self, lines: &[String], from: usize) -> Option { + let re = self.compile()?; + let mut idx = from + 1; + if idx >= lines.len() { + idx = 0; + } + let start = idx; + loop { + if re.is_match(&lines[idx]) { + return Some(idx); + } + idx = (idx + 1) % lines.len(); + if idx == start { + return None; + } + } + } + + pub fn prev_match(&self, lines: &[String], from: usize) -> Option { + let re = self.compile()?; + let len = lines.len(); + if len == 0 { + return None; + } + let mut idx = from.checked_sub(1).unwrap_or(len - 1); + let start = idx; + loop { + if re.is_match(&lines[idx]) { + return Some(idx); + } + if idx == 0 { + idx = len - 1; + } else { + idx -= 1; + } + if idx == start { + return None; + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_search_matches() { + let s = SearchState { + query: "err".into(), + ..Default::default() + }; + assert!(s.matches("ERROR: something failed")); + assert!(!s.matches("INFO: ok")); + } + + #[test] + fn test_next_prev() { + let lines = vec![ + "INFO ok".into(), + "ERROR one".into(), + "INFO fine".into(), + "ERROR two".into(), + ]; + let s = SearchState { + query: "ERROR".into(), + ..Default::default() + }; + assert_eq!(s.next_match(&lines, 0), Some(1)); + assert_eq!(s.next_match(&lines, 1), Some(3)); + assert_eq!(s.next_match(&lines, 3), Some(1)); + assert_eq!(s.prev_match(&lines, 0), Some(3)); + } +} diff --git a/src/ssh.rs b/src/ssh.rs new file mode 100644 index 0000000..cb7e8d5 --- /dev/null +++ b/src/ssh.rs @@ -0,0 +1,146 @@ +use std::io; +use std::process::Stdio; +use std::time::Duration; + +use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader}; +use tokio::process::{Child, Command}; +use tokio::sync::mpsc; +use tokio::time::timeout; + +#[derive(Debug, Clone)] +pub struct SshTarget { + pub args: Vec, +} + +impl SshTarget { + pub fn display(&self) -> String { + self.args.join(" ") + } + + /// Best-effort extraction of the host part from ssh args. + pub fn host(&self) -> String { + let skip_flags: &[&str] = &[ + "-p", "-P", "-i", "-l", "-F", "-o", "-W", "-D", "-L", "-R", "-J", "-c", "-m", "-Q", + "-w", "-b", "-e", "-E", + ]; + let mut iter = self.args.iter().peekable(); + while let Some(arg) = iter.next() { + if arg.starts_with('-') { + // Flag with inline value (e.g. -p22) + let short = arg.get(..2).unwrap_or(arg); + if skip_flags.contains(&short) && arg.len() == 2 { + iter.next(); // skip separate value + } + } else { + return arg.clone(); + } + } + self.display() + } +} + +#[derive(Debug, Clone)] +pub struct SshSession { + pub command: String, + pub target: SshTarget, +} + +impl SshSession { + pub fn new(command: String, target: SshTarget) -> Self { + Self { command, target } + } + + fn base_cmd(&self) -> Command { + let mut cmd = Command::new(&self.command); + cmd.args(&self.target.args); + cmd + } + + pub async fn exec(&self, remote_command: &str, secs: u64) -> io::Result> { + let mut cmd = self.base_cmd(); + cmd.arg("--").arg(remote_command); + cmd.stdout(Stdio::piped()); + cmd.stderr(Stdio::piped()); + + let mut child = cmd.spawn()?; + let dur = Duration::from_secs(secs); + let result = timeout(dur, child.wait()).await; + + match result { + Ok(Ok(status)) => { + let mut stdout = child.stdout.take().unwrap(); + let mut out = Vec::new(); + stdout.read_to_end(&mut out).await?; + if status.success() { + Ok(out) + } else { + let mut stderr = Vec::new(); + if let Some(mut s) = child.stderr.take() { + let _ = s.read_to_end(&mut stderr).await; + } + Err(io::Error::other(format!( + "ssh command failed with status {}: {}", + status, + String::from_utf8_lossy(&stderr) + ))) + } + } + Ok(Err(e)) => Err(io::Error::other(e)), + Err(_) => { + let _ = child.start_kill(); + Err(io::Error::new( + io::ErrorKind::TimedOut, + format!("ssh command timed out after {}s", secs), + )) + } + } + } + + pub fn spawn_stream(&self, remote_command: &str) -> io::Result { + let mut cmd = self.base_cmd(); + cmd.arg("--").arg(remote_command); + cmd.stdout(Stdio::piped()); + cmd.stderr(Stdio::null()); + cmd.kill_on_drop(true); + cmd.spawn() + } + + /// Spawn a remote command and return a channel of lines from stdout. + pub fn stream_lines(&self, remote_command: &str) -> io::Result> { + let mut child = self.spawn_stream(remote_command)?; + let stdout = child.stdout.take().ok_or_else(|| { + io::Error::other("failed to capture stdout") + })?; + + let (tx, rx) = mpsc::unbounded_channel(); + tokio::spawn(async move { + let reader = BufReader::new(stdout); + let mut lines = reader.lines(); + while let Ok(Some(line)) = lines.next_line().await { + if tx.send(line).is_err() { + break; + } + } + let _ = child.wait().await; + }); + Ok(rx) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_host_extraction() { + let t = SshTarget { + args: vec!["-p".into(), "22".into(), "root@192.168.53.3".into()], + }; + assert_eq!(t.host(), "root@192.168.53.3"); + + let t2 = SshTarget { + args: vec!["-p22".into(), "root@example.com".into()], + }; + assert_eq!(t2.host(), "root@example.com"); + } +} diff --git a/src/ui.rs b/src/ui.rs new file mode 100644 index 0000000..429e239 --- /dev/null +++ b/src/ui.rs @@ -0,0 +1,211 @@ +use ratatui::{ + layout::{Alignment, Constraint, Direction, Layout, Margin}, + style::{Color, Modifier, Style}, + text::{Line, Span, Text}, + widgets::{Block, Borders, Clear, List, ListItem, Paragraph, Wrap}, + Frame, +}; + +use crate::app::{App, LogViewer, Screen}; + +pub fn draw(f: &mut Frame, app: &App) { + match app.screen { + Screen::Picker | Screen::PickerSearch => draw_picker(f, app), + Screen::Viewer | Screen::Search => draw_viewer(f, app), + } +} + +fn draw_picker(f: &mut Frame, app: &App) { + let chunks = Layout::default() + .direction(Direction::Vertical) + .margin(1) + .constraints([ + Constraint::Min(8), + Constraint::Length(8), + Constraint::Length(1), + ]) + .split(f.area()); + + let top = Layout::default() + .direction(Direction::Horizontal) + .constraints([Constraint::Percentage(35), Constraint::Percentage(65)]) + .split(chunks[0]); + + draw_log_list(f, app, top[1]); + draw_preview(f, app, chunks[1]); + draw_status(f, app, chunks[2]); + + if app.screen == Screen::PickerSearch { + draw_search_popup(f, app); + } +} + +fn draw_viewer(f: &mut Frame, app: &App) { + let chunks = Layout::default() + .direction(Direction::Vertical) + .margin(1) + .constraints([Constraint::Min(5), Constraint::Length(1)]) + .split(f.area()); + + if let Some(viewer) = &app.viewer { + draw_log_buffer(f, viewer, chunks[0]); + } else { + let p = Paragraph::new("No log selected.").block(default_block(" Viewer ")); + f.render_widget(p, chunks[0]); + } + draw_viewer_status(f, app, chunks[1]); + + if app.screen == Screen::Search { + draw_search_popup(f, app); + } +} + +fn draw_log_list(f: &mut Frame, app: &App, area: ratatui::layout::Rect) { + let items: Vec = app + .filtered_indices + .iter() + .enumerate() + .map(|(i, &idx)| { + let log = &app.logs[idx]; + let style = if i == app.selected_index { + Style::default() + .bg(Color::Blue) + .fg(Color::Black) + .add_modifier(Modifier::BOLD) + } else { + Style::default() + }; + ListItem::new(format!("[{}] {}", log.category(), log)).style(style) + }) + .collect(); + + let title = format!(" Logs ({}/{}) ", app.filtered_indices.len(), app.logs.len()); + let list = List::new(items).block(default_block(&title)); + f.render_widget(list, area); +} + +fn draw_preview(f: &mut Frame, app: &App, area: ratatui::layout::Rect) { + let text = match app.selected_log() { + Some(log) => Text::from(vec![ + Line::from(vec![ + Span::styled("Source: ", Style::default().fg(Color::Yellow)), + Span::raw(log.to_string()), + ]), + Line::from(vec![ + Span::styled("Category: ", Style::default().fg(Color::Yellow)), + Span::raw(log.category()), + ]), + ]), + None => Text::from("No log selected."), + }; + let paragraph = Paragraph::new(text) + .block(default_block(" Preview ")) + .wrap(Wrap { trim: true }); + f.render_widget(paragraph, area); +} + +fn draw_log_buffer(f: &mut Frame, viewer: &LogViewer, area: ratatui::layout::Rect) { + let title = format!(" {} — {} ", viewer.source, if viewer.live { "LIVE" } else { "PAUSED" }); + let visible = viewer.visible_lines(); + + let lines: Vec = visible + .iter() + .enumerate() + .map(|(i, line)| { + let global_idx = viewer + .buffer + .iter() + .position(|l| std::ptr::eq(l.as_ptr(), line.as_ptr())) + .unwrap_or(i); + let is_current = global_idx == viewer.scroll; + let is_match = viewer + .search_cursor + .map(|c| c == global_idx) + .unwrap_or(false); + + let mut style = Style::default(); + if is_current { + style = style + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD); + } + if is_match { + style = style.bg(Color::Yellow).fg(Color::Black); + } + Line::from(Span::styled(line.as_str(), style)) + }) + .collect(); + + let paragraph = Paragraph::new(Text::from(lines)) + .block(default_block(&title)) + .wrap(Wrap { trim: false }); + f.render_widget(paragraph, area); +} + +fn draw_status(f: &mut Frame, app: &App, area: ratatui::layout::Rect) { + let help = "j/k: move | Enter: open | /: filter | r: reload | q: quit"; + let target = app.session.target.host(); + let text = if app.loading { + Text::from("Loading...") + } else { + match &app.message { + Some(msg) => Text::from(format!("{} | {}", target, msg)), + None => Text::from(format!("{} | {}", target, help)), + } + }; + let paragraph = Paragraph::new(text) + .style(Style::default().fg(Color::Gray)) + .alignment(Alignment::Left); + f.render_widget(paragraph, area); +} + +fn draw_viewer_status(f: &mut Frame, app: &App, area: ratatui::layout::Rect) { + let help = "j/k: scroll | g/G: top/bottom | l/Space: live | /: search | n/N: next/prev | s: save | q: back"; + let text = match (&app.viewer, &app.message) { + (Some(v), None) => format!( + "{} | lines: {} | scroll: {} | {}", + if v.live { "LIVE" } else { "PAUSED" }, + v.buffer.len(), + v.scroll, + help + ), + _ => help.to_string(), + }; + let paragraph = Paragraph::new(Text::from(text)).style(Style::default().fg(Color::Gray)); + f.render_widget(paragraph, area); +} + +fn draw_search_popup(f: &mut Frame, app: &App) { + let area = f.area(); + let popup_area = Layout::default() + .direction(Direction::Vertical) + .constraints([ + Constraint::Percentage(30), + Constraint::Length(3), + Constraint::Percentage(70), + ]) + .split(area)[1]; + let popup_area = popup_area.inner(Margin { + horizontal: area.width / 4, + vertical: 0, + }); + + let query = app.current_filter_query(); + let title = if app.screen == Screen::PickerSearch { + " Filter logs " + } else { + " Search in log " + }; + let input = Paragraph::new(query) + .block(default_block(title).border_style(Style::default().fg(Color::Yellow))) + .wrap(Wrap { trim: true }); + f.render_widget(Clear, popup_area); + f.render_widget(input, popup_area); +} + +fn default_block(title: &str) -> Block<'_> { + Block::default() + .title(title) + .borders(Borders::ALL) + .border_style(Style::default().fg(Color::DarkGray)) +}