diff --git a/Cargo.lock b/Cargo.lock index 28ae44d..23795ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,6 +23,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -99,6 +105,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "bstr" version = "0.2.17" @@ -166,7 +178,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", "indexmap", @@ -187,7 +199,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -301,11 +313,11 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +checksum = "77f67c7faacd4db07a939f55d66a983a5355358a1f17d32cc9a8d01d1266b9ce" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossterm_winapi", "libc", "mio", @@ -317,11 +329,11 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f67c7faacd4db07a939f55d66a983a5355358a1f17d32cc9a8d01d1266b9ce" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags", + "bitflags 2.4.1", "crossterm_winapi", "libc", "mio", @@ -333,9 +345,9 @@ dependencies = [ [[package]] name = "crossterm_winapi" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ "winapi", ] @@ -347,7 +359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -374,7 +386,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.107", ] [[package]] @@ -391,7 +403,7 @@ checksum = "ebf883b7aacd7b2aeb2a7b338648ee19f57c140d4ee8e52c68979c6b2f7f2263" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -415,7 +427,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.107", ] [[package]] @@ -426,7 +438,7 @@ checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -437,7 +449,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -455,7 +467,7 @@ dependencies = [ "cc", "clap", "const_format", - "itertools", + "itertools 0.10.5", "lazy_static", "libc", "libmimalloc-sys", @@ -644,7 +656,7 @@ checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -724,6 +736,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +dependencies = [ + "ahash", + "allocator-api2", +] + [[package]] name = "heck" version = "0.4.1" @@ -894,9 +916,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] +[[package]] +name = "indoc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" + [[package]] name = "instant" version = "0.1.12" @@ -925,6 +953,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.5" @@ -1057,7 +1094,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn", + "syn 1.0.107", ] [[package]] @@ -1097,9 +1134,10 @@ dependencies = [ "either", "futures", "grep-cli", - "itertools", + "itertools 0.10.5", "k8s-openapi", "kube", + "ratatui", "serde", "serde_json", "serde_yaml 0.9.17", @@ -1108,7 +1146,6 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "tui", ] [[package]] @@ -1172,6 +1209,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60" +dependencies = [ + "hashbrown 0.14.2", +] + [[package]] name = "memchr" version = "2.5.0" @@ -1334,6 +1380,12 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pem" version = "1.1.1" @@ -1376,7 +1428,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1428,7 +1480,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "version_check", ] @@ -1445,9 +1497,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -1460,9 +1512,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.23" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1503,6 +1555,24 @@ dependencies = [ "getrandom", ] +[[package]] +name = "ratatui" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" +dependencies = [ + "bitflags 2.4.1", + "cassowary", + "crossterm 0.27.0", + "indoc", + "itertools 0.11.0", + "lru", + "paste", + "strum", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "rayon" version = "1.6.1" @@ -1531,7 +1601,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1613,7 +1683,7 @@ version = "0.36.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -1654,6 +1724,12 @@ dependencies = [ "base64 0.21.0", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.12" @@ -1699,7 +1775,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 1.0.107", ] [[package]] @@ -1740,7 +1816,7 @@ version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -1784,7 +1860,7 @@ checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1795,7 +1871,7 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1846,9 +1922,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", @@ -1917,6 +1993,28 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.38", +] + [[package]] name = "syn" version = "1.0.107" @@ -1928,6 +2026,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.3.0" @@ -1997,7 +2106,7 @@ checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2063,7 +2172,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2116,7 +2225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-util", @@ -2162,7 +2271,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -2239,19 +2348,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "tui" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" -dependencies = [ - "bitflags", - "cassowary", - "crossterm 0.25.0", - "unicode-segmentation", - "unicode-width", -] - [[package]] name = "typed-arena" version = "2.0.2" @@ -2380,7 +2476,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-shared", ] @@ -2402,7 +2498,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index dc1ca6a..88caabc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,4 @@ [workspace] default-members = ["kubectl-watch"] -members = [ - "kubectl-watch", - "difftastic-lib", -] +members = ["kubectl-watch", "difftastic-lib"] +resolver = "2" diff --git a/README.md b/README.md index c335452..1f90e62 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ kubectl-watch {resource} -include-managed-fields ## Acknowledgment -- [tui-rs](https://github.com/fdehau/tui-rs) +- [ratatui](https://github.com/ratatui-org/ratatui) - [difftastic](https://github.com/Wilfred/difftastic) - [kube-rs](https://github.com/kube-rs/kube-rs) - [rust](https://github.com/rust-lang/rust) diff --git a/difftastic-lib/Cargo.toml b/difftastic-lib/Cargo.toml index 5545319..a4d1269 100644 --- a/difftastic-lib/Cargo.toml +++ b/difftastic-lib/Cargo.toml @@ -8,7 +8,7 @@ version = "0.0.2" authors = ["Wilfred Hughes ", "chengqinglin "] keywords = ["diff", "syntax"] categories = ["development-tools", "command-line-utilities", "parser-implementations"] -edition = "2018" +edition = "2021" include = [ "/build.rs", "/src/", @@ -63,7 +63,7 @@ version_check = "0.9.4" # flamegraph. # # https://doc.rust-lang.org/cargo/reference/profiles.html#release -debug = false +# debug = false [[bin]] name = "difft" diff --git a/kubectl-watch/Cargo.toml b/kubectl-watch/Cargo.toml index 9d53896..f7c3c9f 100644 --- a/kubectl-watch/Cargo.toml +++ b/kubectl-watch/Cargo.toml @@ -12,17 +12,26 @@ readme = "../README.md" [dependencies] anyhow = "1.0.44" -clap = { version = "3.1.9", default-features = false, features = ["std", "cargo", "derive"] } +clap = { version = "3.1.9", default-features = false, features = [ + "std", + "cargo", + "derive", +] } colored = "2" crossterm = "0.26" # difftastic-lib = "0.0.1" -difftastic-lib = { path = "../difftastic-lib" , version = "0.0.2"} +difftastic-lib = { path = "../difftastic-lib", version = "0.0.2" } edit = "0.1.3" either = "1.6.1" futures = "0.3.17" grep-cli = "0.1.6" itertools = "0.10.5" -kube = { version = "0.78.0", default-features = false, features = ["runtime", "derive", "client", "rustls-tls"] } +kube = { version = "0.78.0", default-features = false, features = [ + "runtime", + "derive", + "client", + "rustls-tls", +] } k8s-openapi = { version = "0.17.0", features = ["v1_24"] } serde = { version = "1.0.144", features = ["derive"] } serde_json = "1.0.85" @@ -32,4 +41,4 @@ tracing = "0.1.29" tracing-subscriber = "0.3.3" terminal_size = "0.2.1" term_size = "0.3.2" -tui = "0.19" +ratatui = "0.24.0" diff --git a/kubectl-watch/src/diff/difft.rs b/kubectl-watch/src/diff/difft.rs index fd27ef9..a5b43b1 100644 --- a/kubectl-watch/src/diff/difft.rs +++ b/kubectl-watch/src/diff/difft.rs @@ -6,12 +6,12 @@ use crate::persistent; use difft_lib::{diff_file, options, print_diff_result, tui_diff_result, FgColor}; use kube::api::DynamicObject; -use std::path::PathBuf; -use tui::{ +use ratatui::{ style::{Color, Style}, - text::{Span, Spans}, + text::{Line, Span}, widgets::{Paragraph, Wrap}, }; +use std::path::PathBuf; pub struct Difft { include_managed_fields: bool, @@ -127,7 +127,7 @@ fn to_paragraph<'a>(result: Vec>) -> Paragraph<'a> { Span::styled(content.clone(), Style::default().fg(c)) }) .collect::>(); - Spans::from(spans) + Line::from(spans) }) .collect::>(), ) diff --git a/kubectl-watch/src/diff/mod.rs b/kubectl-watch/src/diff/mod.rs index b366a40..c00fa26 100644 --- a/kubectl-watch/src/diff/mod.rs +++ b/kubectl-watch/src/diff/mod.rs @@ -6,7 +6,7 @@ use crate::options; use kube::api::DynamicObject; use std::path::PathBuf; -use tui::widgets::Paragraph; +use ratatui::widgets::Paragraph; pub trait Diff<'a> { fn diff(&mut self, minus_file: PathBuf, plus_file: PathBuf) -> std::io::Result; diff --git a/kubectl-watch/src/output/tui.rs b/kubectl-watch/src/output/tui.rs index c418c5d..0395f81 100644 --- a/kubectl-watch/src/output/tui.rs +++ b/kubectl-watch/src/output/tui.rs @@ -11,9 +11,7 @@ use crossterm::{ terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; use kube::{api::DynamicObject, ResourceExt}; -use std::{collections::HashMap, io}; -use tokio::sync::mpsc; -use tui::{ +use ratatui::{ backend::{Backend, CrosstermBackend}, layout::{Constraint, Direction, Layout, Rect}, style::{Color, Style}, @@ -22,6 +20,8 @@ use tui::{ Frame, Terminal, }; +use std::{collections::HashMap, io}; +use tokio::sync::mpsc; impl UID for DynamicObject { fn resource_version(&self) -> String { @@ -262,7 +262,7 @@ async fn run_tui( } } -fn ui(f: &mut Frame, ctrl: &mut Controller) { +fn ui(f: &mut Frame, ctrl: &mut Controller) { let chunks = Layout::default() .constraints([Constraint::Length(10), Constraint::Min(10)].as_ref()) .split(f.size()); @@ -271,10 +271,7 @@ fn ui(f: &mut Frame, ctrl: &mut Controller) { draw_diff(f, ctrl, chunks[1]); } -fn draw_resources_event(f: &mut Frame, ctrl: &mut Controller, area: Rect) -where - B: Backend, -{ +fn draw_resources_event(f: &mut Frame, ctrl: &mut Controller, area: Rect) { let selected_style = Style::default().bg(Color::Black).fg(Color::LightRed); let header = Row::new(ctrl.get_header()) .style(Style::default().fg(Color::LightBlue)) @@ -311,10 +308,7 @@ where f.render_stateful_widget(t, area, &mut ctrl.state); } -fn draw_diff(f: &mut Frame, ctrl: &mut Controller, area: Rect) -where - B: Backend, -{ +fn draw_diff(f: &mut Frame, ctrl: &mut Controller, area: Rect) { f.render_widget( Block::default().borders(Borders::ALL).title("Diff Result"), area,