this repo has no description

feat: return_code

+25 -11
+9 -9
Cargo.lock
··· 102 102 103 103 [[package]] 104 104 name = "clap" 105 - version = "4.5.54" 105 + version = "4.5.60" 106 106 source = "registry+https://github.com/rust-lang/crates.io-index" 107 - checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" 107 + checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" 108 108 dependencies = [ 109 109 "clap_builder", 110 110 "clap_derive", ··· 112 112 113 113 [[package]] 114 114 name = "clap_builder" 115 - version = "4.5.54" 115 + version = "4.5.60" 116 116 source = "registry+https://github.com/rust-lang/crates.io-index" 117 - checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" 117 + checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" 118 118 dependencies = [ 119 119 "anstream", 120 120 "anstyle", ··· 124 124 125 125 [[package]] 126 126 name = "clap_derive" 127 - version = "4.5.49" 127 + version = "4.5.55" 128 128 source = "registry+https://github.com/rust-lang/crates.io-index" 129 - checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" 129 + checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" 130 130 dependencies = [ 131 131 "heck", 132 132 "proc-macro2", ··· 136 136 137 137 [[package]] 138 138 name = "clap_lex" 139 - version = "0.7.7" 139 + version = "1.0.0" 140 140 source = "registry+https://github.com/rust-lang/crates.io-index" 141 - checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" 141 + checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" 142 142 143 143 [[package]] 144 144 name = "color-eyre" ··· 337 337 338 338 [[package]] 339 339 name = "lix-diff" 340 - version = "1.3.0" 340 + version = "1.4.0" 341 341 dependencies = [ 342 342 "clap", 343 343 "color-eyre",
+2 -2
Cargo.toml
··· 1 1 [package] 2 2 name = "lix-diff" 3 - version = "1.3.0" 3 + version = "1.4.0" 4 4 license = "MIT" 5 5 description = "A lix plugin for diffing two generations" 6 6 homepage = "https://github.com/tgirlcloud/lix-diff" ··· 8 8 edition = "2024" 9 9 10 10 [dependencies] 11 - clap = { version = "4.5.54", features = ["derive"] } 11 + clap = { version = "4.5.60", features = ["derive"] } 12 12 color-eyre = "0.6.5" 13 13 humansize = "2.1.3" 14 14 nu-ansi-term = "0.50.3"
+4
src/diff.rs
··· 39 39 by_size: false, 40 40 } 41 41 } 42 + 43 + pub fn is_empty(&self) -> bool { 44 + self.added.is_empty() && self.removed.is_empty() && self.changed.is_empty() 45 + } 42 46 } 43 47 44 48 impl std::fmt::Display for PackageListDiff {
+10
src/main.rs
··· 14 14 15 15 use self::parser::DiffRoot; 16 16 17 + #[allow(clippy::struct_excessive_bools)] 17 18 #[derive(Parser, PartialEq, Debug)] 18 19 /// List the package differences between two `NixOS` generations 19 20 struct Args { ··· 39 40 /// disable the header showing the generation paths 40 41 #[arg(long)] 41 42 no_header: bool, 43 + 44 + /// add a return code indicating whether there are changes or no (1 if there are no changes, 0 45 + /// otherwise) 46 + #[arg(short, long = "return")] 47 + return_code: bool, 42 48 } 43 49 44 50 fn main() -> Result<()> { ··· 95 101 } 96 102 97 103 println!("{packages}"); 104 + 105 + if args.return_code { 106 + std::process::exit(if packages.is_empty() { 1 } else { 0 }); 107 + } 98 108 99 109 Ok(()) 100 110 }