this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(tar): add tar compression

+421 -2
+361
Cargo.lock
··· 3 3 version = 3 4 4 5 5 [[package]] 6 + name = "anstream" 7 + version = "0.2.6" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f" 10 + dependencies = [ 11 + "anstyle", 12 + "anstyle-parse", 13 + "anstyle-wincon", 14 + "concolor-override", 15 + "concolor-query", 16 + "is-terminal", 17 + "utf8parse", 18 + ] 19 + 20 + [[package]] 21 + name = "anstyle" 22 + version = "0.3.5" 23 + source = "registry+https://github.com/rust-lang/crates.io-index" 24 + checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" 25 + 26 + [[package]] 27 + name = "anstyle-parse" 28 + version = "0.1.1" 29 + source = "registry+https://github.com/rust-lang/crates.io-index" 30 + checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116" 31 + dependencies = [ 32 + "utf8parse", 33 + ] 34 + 35 + [[package]] 36 + name = "anstyle-wincon" 37 + version = "0.2.0" 38 + source = "registry+https://github.com/rust-lang/crates.io-index" 39 + checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" 40 + dependencies = [ 41 + "anstyle", 42 + "windows-sys", 43 + ] 44 + 45 + [[package]] 46 + name = "bitflags" 47 + version = "1.3.2" 48 + source = "registry+https://github.com/rust-lang/crates.io-index" 49 + checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 50 + 51 + [[package]] 52 + name = "cc" 53 + version = "1.0.79" 54 + source = "registry+https://github.com/rust-lang/crates.io-index" 55 + checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 56 + 57 + [[package]] 58 + name = "cfg-if" 59 + version = "1.0.0" 60 + source = "registry+https://github.com/rust-lang/crates.io-index" 61 + checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 62 + 63 + [[package]] 64 + name = "clap" 65 + version = "4.2.1" 66 + source = "registry+https://github.com/rust-lang/crates.io-index" 67 + checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" 68 + dependencies = [ 69 + "clap_builder", 70 + "clap_derive", 71 + "once_cell", 72 + ] 73 + 74 + [[package]] 75 + name = "clap_builder" 76 + version = "4.2.1" 77 + source = "registry+https://github.com/rust-lang/crates.io-index" 78 + checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f" 79 + dependencies = [ 80 + "anstream", 81 + "anstyle", 82 + "bitflags", 83 + "clap_lex", 84 + "strsim", 85 + ] 86 + 87 + [[package]] 88 + name = "clap_derive" 89 + version = "4.2.0" 90 + source = "registry+https://github.com/rust-lang/crates.io-index" 91 + checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" 92 + dependencies = [ 93 + "heck", 94 + "proc-macro2", 95 + "quote", 96 + "syn", 97 + ] 98 + 99 + [[package]] 100 + name = "clap_lex" 101 + version = "0.4.1" 102 + source = "registry+https://github.com/rust-lang/crates.io-index" 103 + checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" 104 + 105 + [[package]] 6 106 name = "cmprss" 7 107 version = "0.0.1" 108 + dependencies = [ 109 + "clap", 110 + "tar", 111 + ] 112 + 113 + [[package]] 114 + name = "concolor-override" 115 + version = "1.0.0" 116 + source = "registry+https://github.com/rust-lang/crates.io-index" 117 + checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f" 118 + 119 + [[package]] 120 + name = "concolor-query" 121 + version = "0.3.3" 122 + source = "registry+https://github.com/rust-lang/crates.io-index" 123 + checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" 124 + dependencies = [ 125 + "windows-sys", 126 + ] 127 + 128 + [[package]] 129 + name = "errno" 130 + version = "0.3.0" 131 + source = "registry+https://github.com/rust-lang/crates.io-index" 132 + checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" 133 + dependencies = [ 134 + "errno-dragonfly", 135 + "libc", 136 + "windows-sys", 137 + ] 138 + 139 + [[package]] 140 + name = "errno-dragonfly" 141 + version = "0.1.2" 142 + source = "registry+https://github.com/rust-lang/crates.io-index" 143 + checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" 144 + dependencies = [ 145 + "cc", 146 + "libc", 147 + ] 148 + 149 + [[package]] 150 + name = "filetime" 151 + version = "0.2.20" 152 + source = "registry+https://github.com/rust-lang/crates.io-index" 153 + checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" 154 + dependencies = [ 155 + "cfg-if", 156 + "libc", 157 + "redox_syscall", 158 + "windows-sys", 159 + ] 160 + 161 + [[package]] 162 + name = "heck" 163 + version = "0.4.1" 164 + source = "registry+https://github.com/rust-lang/crates.io-index" 165 + checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 166 + 167 + [[package]] 168 + name = "hermit-abi" 169 + version = "0.3.1" 170 + source = "registry+https://github.com/rust-lang/crates.io-index" 171 + checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" 172 + 173 + [[package]] 174 + name = "io-lifetimes" 175 + version = "1.0.9" 176 + source = "registry+https://github.com/rust-lang/crates.io-index" 177 + checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" 178 + dependencies = [ 179 + "hermit-abi", 180 + "libc", 181 + "windows-sys", 182 + ] 183 + 184 + [[package]] 185 + name = "is-terminal" 186 + version = "0.4.6" 187 + source = "registry+https://github.com/rust-lang/crates.io-index" 188 + checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" 189 + dependencies = [ 190 + "hermit-abi", 191 + "io-lifetimes", 192 + "rustix", 193 + "windows-sys", 194 + ] 195 + 196 + [[package]] 197 + name = "libc" 198 + version = "0.2.140" 199 + source = "registry+https://github.com/rust-lang/crates.io-index" 200 + checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" 201 + 202 + [[package]] 203 + name = "linux-raw-sys" 204 + version = "0.3.1" 205 + source = "registry+https://github.com/rust-lang/crates.io-index" 206 + checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" 207 + 208 + [[package]] 209 + name = "once_cell" 210 + version = "1.17.1" 211 + source = "registry+https://github.com/rust-lang/crates.io-index" 212 + checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" 213 + 214 + [[package]] 215 + name = "proc-macro2" 216 + version = "1.0.55" 217 + source = "registry+https://github.com/rust-lang/crates.io-index" 218 + checksum = "1d0dd4be24fcdcfeaa12a432d588dc59bbad6cad3510c67e74a2b6b2fc950564" 219 + dependencies = [ 220 + "unicode-ident", 221 + ] 222 + 223 + [[package]] 224 + name = "quote" 225 + version = "1.0.26" 226 + source = "registry+https://github.com/rust-lang/crates.io-index" 227 + checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" 228 + dependencies = [ 229 + "proc-macro2", 230 + ] 231 + 232 + [[package]] 233 + name = "redox_syscall" 234 + version = "0.2.16" 235 + source = "registry+https://github.com/rust-lang/crates.io-index" 236 + checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 237 + dependencies = [ 238 + "bitflags", 239 + ] 240 + 241 + [[package]] 242 + name = "rustix" 243 + version = "0.37.6" 244 + source = "registry+https://github.com/rust-lang/crates.io-index" 245 + checksum = "d097081ed288dfe45699b72f5b5d648e5f15d64d900c7080273baa20c16a6849" 246 + dependencies = [ 247 + "bitflags", 248 + "errno", 249 + "io-lifetimes", 250 + "libc", 251 + "linux-raw-sys", 252 + "windows-sys", 253 + ] 254 + 255 + [[package]] 256 + name = "strsim" 257 + version = "0.10.0" 258 + source = "registry+https://github.com/rust-lang/crates.io-index" 259 + checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 260 + 261 + [[package]] 262 + name = "syn" 263 + version = "2.0.13" 264 + source = "registry+https://github.com/rust-lang/crates.io-index" 265 + checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" 266 + dependencies = [ 267 + "proc-macro2", 268 + "quote", 269 + "unicode-ident", 270 + ] 271 + 272 + [[package]] 273 + name = "tar" 274 + version = "0.4.38" 275 + source = "registry+https://github.com/rust-lang/crates.io-index" 276 + checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" 277 + dependencies = [ 278 + "filetime", 279 + "libc", 280 + "xattr", 281 + ] 282 + 283 + [[package]] 284 + name = "unicode-ident" 285 + version = "1.0.8" 286 + source = "registry+https://github.com/rust-lang/crates.io-index" 287 + checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" 288 + 289 + [[package]] 290 + name = "utf8parse" 291 + version = "0.2.1" 292 + source = "registry+https://github.com/rust-lang/crates.io-index" 293 + checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" 294 + 295 + [[package]] 296 + name = "windows-sys" 297 + version = "0.45.0" 298 + source = "registry+https://github.com/rust-lang/crates.io-index" 299 + checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 300 + dependencies = [ 301 + "windows-targets", 302 + ] 303 + 304 + [[package]] 305 + name = "windows-targets" 306 + version = "0.42.2" 307 + source = "registry+https://github.com/rust-lang/crates.io-index" 308 + checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 309 + dependencies = [ 310 + "windows_aarch64_gnullvm", 311 + "windows_aarch64_msvc", 312 + "windows_i686_gnu", 313 + "windows_i686_msvc", 314 + "windows_x86_64_gnu", 315 + "windows_x86_64_gnullvm", 316 + "windows_x86_64_msvc", 317 + ] 318 + 319 + [[package]] 320 + name = "windows_aarch64_gnullvm" 321 + version = "0.42.2" 322 + source = "registry+https://github.com/rust-lang/crates.io-index" 323 + checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 324 + 325 + [[package]] 326 + name = "windows_aarch64_msvc" 327 + version = "0.42.2" 328 + source = "registry+https://github.com/rust-lang/crates.io-index" 329 + checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 330 + 331 + [[package]] 332 + name = "windows_i686_gnu" 333 + version = "0.42.2" 334 + source = "registry+https://github.com/rust-lang/crates.io-index" 335 + checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 336 + 337 + [[package]] 338 + name = "windows_i686_msvc" 339 + version = "0.42.2" 340 + source = "registry+https://github.com/rust-lang/crates.io-index" 341 + checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 342 + 343 + [[package]] 344 + name = "windows_x86_64_gnu" 345 + version = "0.42.2" 346 + source = "registry+https://github.com/rust-lang/crates.io-index" 347 + checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 348 + 349 + [[package]] 350 + name = "windows_x86_64_gnullvm" 351 + version = "0.42.2" 352 + source = "registry+https://github.com/rust-lang/crates.io-index" 353 + checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 354 + 355 + [[package]] 356 + name = "windows_x86_64_msvc" 357 + version = "0.42.2" 358 + source = "registry+https://github.com/rust-lang/crates.io-index" 359 + checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 360 + 361 + [[package]] 362 + name = "xattr" 363 + version = "0.2.3" 364 + source = "registry+https://github.com/rust-lang/crates.io-index" 365 + checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" 366 + dependencies = [ 367 + "libc", 368 + ]
+3
Cargo.toml
··· 12 12 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 13 13 14 14 [dependencies] 15 + clap = { version = "4.2.1", features = ["derive"] } 16 + tar = "0.4.38" 17 +
+5 -1
README.md
··· 1 1 # cmprss 2 2 3 - (UNIMPLEMENTED) A compression tool for the CLI 3 + (UNIMPLEMENTED) A compression multi-tool for the CLI 4 + 5 + ## Supported formats 6 + 7 + - tar (compress only)
+29 -1
src/main.rs
··· 1 + mod tar; 2 + 3 + use clap::Parser; 4 + use std::path::Path; 5 + 6 + /// A compression multi-tool 7 + #[derive(Parser, Debug)] 8 + #[command(author, version, about, long_about = None)] 9 + struct Args { 10 + /// Input file 11 + #[arg(index = 1)] 12 + input: String, 13 + 14 + /// Output filename 15 + /// If it's not provided, the extension is inferred from the compression type. 16 + #[arg(index = 2)] 17 + output: Option<String>, 18 + } 19 + 1 20 fn main() { 2 - println!("Hello, world!"); 21 + let args = Args::parse(); 22 + let out = match args.output { 23 + Some(file) => file, 24 + None => { 25 + // Append tar to the base file name as a default. 26 + let p = Path::new(&args.input); 27 + format!("{}{}", p.file_name().unwrap().to_str().unwrap(), ".tar") 28 + } 29 + }; 30 + tar::compress(Path::new(&args.input), out); 3 31 }
+23
src/tar.rs
··· 1 + extern crate tar; 2 + 3 + use std::fs::File; 4 + use std::path::Path; 5 + use tar::Builder; 6 + 7 + /// Compress an input file or directory into a tar archive. 8 + pub fn compress<P: AsRef<Path>>(in_file: &Path, out_file: P) { 9 + let mut archive = Builder::new(File::create(out_file).unwrap()); 10 + if in_file.is_file() { 11 + archive 12 + .append_file( 13 + in_file.file_name().unwrap(), 14 + &mut File::open(in_file).unwrap(), 15 + ) 16 + .unwrap(); 17 + } else if in_file.is_dir() { 18 + archive 19 + .append_dir_all(in_file.file_name().unwrap(), in_file) 20 + .unwrap(); 21 + } 22 + archive.finish().unwrap(); 23 + }