├── .cargo └── config ├── .github └── workflows │ └── rust.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE-MIT.md ├── README.md ├── build.rs ├── screencast.gif └── src ├── bro.rs └── main.rs /.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | rustflags = "-C target-cpu=native" 3 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Build 17 | run: cargo build --verbose 18 | - name: Lint 19 | run: cargo clippy 20 | # - name: Run tests 21 | # run: cargo test --verbose 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | /target 4 | version 5 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "adler" 7 | version = "1.0.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 10 | 11 | [[package]] 12 | name = "aho-corasick" 13 | version = "1.0.5" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" 16 | dependencies = [ 17 | "memchr", 18 | ] 19 | 20 | [[package]] 21 | name = "ansi_colours" 22 | version = "1.2.2" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "6a1558bd2075d341b9ca698ec8eb6fcc55a746b1fc4255585aad5b141d918a80" 25 | dependencies = [ 26 | "rgb", 27 | ] 28 | 29 | [[package]] 30 | name = "anstyle" 31 | version = "1.0.3" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" 34 | 35 | [[package]] 36 | name = "autocfg" 37 | version = "1.1.0" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 40 | 41 | [[package]] 42 | name = "base64" 43 | version = "0.21.4" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" 46 | 47 | [[package]] 48 | name = "bat" 49 | version = "0.24.0" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "9dcc9e5637c2330d8eb7b920f2aa5d9e184446c258466f825ea1412c7614cc86" 52 | dependencies = [ 53 | "ansi_colours", 54 | "bincode", 55 | "bytesize", 56 | "clircle", 57 | "console", 58 | "content_inspector", 59 | "encoding_rs", 60 | "flate2", 61 | "globset", 62 | "grep-cli", 63 | "home", 64 | "nu-ansi-term", 65 | "once_cell", 66 | "path_abs", 67 | "plist", 68 | "semver", 69 | "serde", 70 | "serde_yaml", 71 | "shell-words", 72 | "syntect", 73 | "thiserror", 74 | "unicode-width", 75 | ] 76 | 77 | [[package]] 78 | name = "bincode" 79 | version = "1.3.1" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" 82 | dependencies = [ 83 | "byteorder", 84 | "serde", 85 | ] 86 | 87 | [[package]] 88 | name = "bit-set" 89 | version = "0.5.3" 90 | source = "registry+https://github.com/rust-lang/crates.io-index" 91 | checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" 92 | dependencies = [ 93 | "bit-vec", 94 | ] 95 | 96 | [[package]] 97 | name = "bit-vec" 98 | version = "0.6.3" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" 101 | 102 | [[package]] 103 | name = "bitflags" 104 | version = "1.2.1" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 107 | 108 | [[package]] 109 | name = "bropages" 110 | version = "1.5.0" 111 | dependencies = [ 112 | "bat", 113 | "clap", 114 | "ureq", 115 | ] 116 | 117 | [[package]] 118 | name = "bstr" 119 | version = "1.6.2" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" 122 | dependencies = [ 123 | "memchr", 124 | "regex-automata", 125 | "serde", 126 | ] 127 | 128 | [[package]] 129 | name = "bytemuck" 130 | version = "1.11.0" 131 | source = "registry+https://github.com/rust-lang/crates.io-index" 132 | checksum = "a5377c8865e74a160d21f29c2d40669f53286db6eab59b88540cbb12ffc8b835" 133 | 134 | [[package]] 135 | name = "byteorder" 136 | version = "1.3.4" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" 139 | 140 | [[package]] 141 | name = "bytesize" 142 | version = "1.3.0" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" 145 | 146 | [[package]] 147 | name = "cfg-if" 148 | version = "0.1.10" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 151 | 152 | [[package]] 153 | name = "cfg-if" 154 | version = "1.0.0" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 157 | 158 | [[package]] 159 | name = "clap" 160 | version = "4.5.4" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" 163 | dependencies = [ 164 | "clap_builder", 165 | ] 166 | 167 | [[package]] 168 | name = "clap_builder" 169 | version = "4.5.2" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" 172 | dependencies = [ 173 | "anstyle", 174 | "clap_lex", 175 | "strsim", 176 | ] 177 | 178 | [[package]] 179 | name = "clap_lex" 180 | version = "0.7.0" 181 | source = "registry+https://github.com/rust-lang/crates.io-index" 182 | checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" 183 | 184 | [[package]] 185 | name = "clircle" 186 | version = "0.4.0" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "c8e87cbed5354f17bd8ca8821a097fb62599787fe8f611743fad7ee156a0a600" 189 | dependencies = [ 190 | "cfg-if 1.0.0", 191 | "libc", 192 | "serde", 193 | "winapi", 194 | ] 195 | 196 | [[package]] 197 | name = "console" 198 | version = "0.15.7" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" 201 | dependencies = [ 202 | "encode_unicode", 203 | "lazy_static", 204 | "libc", 205 | "unicode-width", 206 | "windows-sys 0.45.0", 207 | ] 208 | 209 | [[package]] 210 | name = "content_inspector" 211 | version = "0.2.4" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" 214 | dependencies = [ 215 | "memchr", 216 | ] 217 | 218 | [[package]] 219 | name = "crc32fast" 220 | version = "1.2.1" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" 223 | dependencies = [ 224 | "cfg-if 1.0.0", 225 | ] 226 | 227 | [[package]] 228 | name = "deranged" 229 | version = "0.3.8" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" 232 | 233 | [[package]] 234 | name = "encode_unicode" 235 | version = "0.3.6" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 238 | 239 | [[package]] 240 | name = "encoding_rs" 241 | version = "0.8.33" 242 | source = "registry+https://github.com/rust-lang/crates.io-index" 243 | checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" 244 | dependencies = [ 245 | "cfg-if 1.0.0", 246 | ] 247 | 248 | [[package]] 249 | name = "equivalent" 250 | version = "1.0.1" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 253 | 254 | [[package]] 255 | name = "fancy-regex" 256 | version = "0.7.1" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "9d6b8560a05112eb52f04b00e5d3790c0dd75d9d980eb8a122fb23b92a623ccf" 259 | dependencies = [ 260 | "bit-set", 261 | "regex", 262 | ] 263 | 264 | [[package]] 265 | name = "flate2" 266 | version = "1.0.24" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" 269 | dependencies = [ 270 | "crc32fast", 271 | "miniz_oxide", 272 | ] 273 | 274 | [[package]] 275 | name = "fnv" 276 | version = "1.0.7" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 279 | 280 | [[package]] 281 | name = "globset" 282 | version = "0.4.13" 283 | source = "registry+https://github.com/rust-lang/crates.io-index" 284 | checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" 285 | dependencies = [ 286 | "aho-corasick", 287 | "bstr", 288 | "fnv", 289 | "log", 290 | "regex", 291 | ] 292 | 293 | [[package]] 294 | name = "grep-cli" 295 | version = "0.1.9" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "8fe4bdbf4300c8b039f5d7eec7fbc6760d2c85bb15ac7499c4d235667f6d747a" 298 | dependencies = [ 299 | "bstr", 300 | "globset", 301 | "lazy_static", 302 | "log", 303 | "regex", 304 | "same-file", 305 | "termcolor", 306 | "winapi-util", 307 | ] 308 | 309 | [[package]] 310 | name = "hashbrown" 311 | version = "0.12.3" 312 | source = "registry+https://github.com/rust-lang/crates.io-index" 313 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 314 | 315 | [[package]] 316 | name = "hashbrown" 317 | version = "0.14.3" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" 320 | 321 | [[package]] 322 | name = "home" 323 | version = "0.5.9" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" 326 | dependencies = [ 327 | "windows-sys 0.52.0", 328 | ] 329 | 330 | [[package]] 331 | name = "idna" 332 | version = "0.2.0" 333 | source = "registry+https://github.com/rust-lang/crates.io-index" 334 | checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" 335 | dependencies = [ 336 | "matches", 337 | "unicode-bidi", 338 | "unicode-normalization", 339 | ] 340 | 341 | [[package]] 342 | name = "indexmap" 343 | version = "1.9.3" 344 | source = "registry+https://github.com/rust-lang/crates.io-index" 345 | checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" 346 | dependencies = [ 347 | "autocfg", 348 | "hashbrown 0.12.3", 349 | ] 350 | 351 | [[package]] 352 | name = "indexmap" 353 | version = "2.2.6" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" 356 | dependencies = [ 357 | "equivalent", 358 | "hashbrown 0.14.3", 359 | ] 360 | 361 | [[package]] 362 | name = "itoa" 363 | version = "1.0.9" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" 366 | 367 | [[package]] 368 | name = "lazy_static" 369 | version = "1.4.0" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 372 | 373 | [[package]] 374 | name = "libc" 375 | version = "0.2.148" 376 | source = "registry+https://github.com/rust-lang/crates.io-index" 377 | checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" 378 | 379 | [[package]] 380 | name = "line-wrap" 381 | version = "0.1.1" 382 | source = "registry+https://github.com/rust-lang/crates.io-index" 383 | checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" 384 | dependencies = [ 385 | "safemem", 386 | ] 387 | 388 | [[package]] 389 | name = "log" 390 | version = "0.4.8" 391 | source = "registry+https://github.com/rust-lang/crates.io-index" 392 | checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 393 | dependencies = [ 394 | "cfg-if 0.1.10", 395 | ] 396 | 397 | [[package]] 398 | name = "matches" 399 | version = "0.1.8" 400 | source = "registry+https://github.com/rust-lang/crates.io-index" 401 | checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 402 | 403 | [[package]] 404 | name = "memchr" 405 | version = "2.6.3" 406 | source = "registry+https://github.com/rust-lang/crates.io-index" 407 | checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" 408 | 409 | [[package]] 410 | name = "miniz_oxide" 411 | version = "0.5.3" 412 | source = "registry+https://github.com/rust-lang/crates.io-index" 413 | checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" 414 | dependencies = [ 415 | "adler", 416 | ] 417 | 418 | [[package]] 419 | name = "nu-ansi-term" 420 | version = "0.49.0" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68" 423 | dependencies = [ 424 | "windows-sys 0.48.0", 425 | ] 426 | 427 | [[package]] 428 | name = "once_cell" 429 | version = "1.18.0" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" 432 | 433 | [[package]] 434 | name = "path_abs" 435 | version = "0.5.0" 436 | source = "registry+https://github.com/rust-lang/crates.io-index" 437 | checksum = "eb6b8e6dede0bf94e9300e669f335ba92d5fc9fc8be7f4b1ca8a05206489388c" 438 | dependencies = [ 439 | "std_prelude", 440 | ] 441 | 442 | [[package]] 443 | name = "percent-encoding" 444 | version = "2.1.0" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 447 | 448 | [[package]] 449 | name = "plist" 450 | version = "1.5.0" 451 | source = "registry+https://github.com/rust-lang/crates.io-index" 452 | checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" 453 | dependencies = [ 454 | "base64", 455 | "indexmap 1.9.3", 456 | "line-wrap", 457 | "quick-xml", 458 | "serde", 459 | "time", 460 | ] 461 | 462 | [[package]] 463 | name = "proc-macro2" 464 | version = "1.0.67" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" 467 | dependencies = [ 468 | "unicode-ident", 469 | ] 470 | 471 | [[package]] 472 | name = "quick-xml" 473 | version = "0.29.0" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" 476 | dependencies = [ 477 | "memchr", 478 | ] 479 | 480 | [[package]] 481 | name = "quote" 482 | version = "1.0.33" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 485 | dependencies = [ 486 | "proc-macro2", 487 | ] 488 | 489 | [[package]] 490 | name = "regex" 491 | version = "1.9.5" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" 494 | dependencies = [ 495 | "aho-corasick", 496 | "memchr", 497 | "regex-automata", 498 | "regex-syntax 0.7.5", 499 | ] 500 | 501 | [[package]] 502 | name = "regex-automata" 503 | version = "0.3.8" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" 506 | dependencies = [ 507 | "aho-corasick", 508 | "memchr", 509 | "regex-syntax 0.7.5", 510 | ] 511 | 512 | [[package]] 513 | name = "regex-syntax" 514 | version = "0.6.27" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" 517 | 518 | [[package]] 519 | name = "regex-syntax" 520 | version = "0.7.5" 521 | source = "registry+https://github.com/rust-lang/crates.io-index" 522 | checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" 523 | 524 | [[package]] 525 | name = "rgb" 526 | version = "0.8.33" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "c3b221de559e4a29df3b957eec92bc0de6bc8eaf6ca9cfed43e5e1d67ff65a34" 529 | dependencies = [ 530 | "bytemuck", 531 | ] 532 | 533 | [[package]] 534 | name = "ryu" 535 | version = "1.0.2" 536 | source = "registry+https://github.com/rust-lang/crates.io-index" 537 | checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" 538 | 539 | [[package]] 540 | name = "safemem" 541 | version = "0.3.3" 542 | source = "registry+https://github.com/rust-lang/crates.io-index" 543 | checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" 544 | 545 | [[package]] 546 | name = "same-file" 547 | version = "1.0.6" 548 | source = "registry+https://github.com/rust-lang/crates.io-index" 549 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 550 | dependencies = [ 551 | "winapi-util", 552 | ] 553 | 554 | [[package]] 555 | name = "semver" 556 | version = "1.0.12" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" 559 | 560 | [[package]] 561 | name = "serde" 562 | version = "1.0.188" 563 | source = "registry+https://github.com/rust-lang/crates.io-index" 564 | checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" 565 | dependencies = [ 566 | "serde_derive", 567 | ] 568 | 569 | [[package]] 570 | name = "serde_derive" 571 | version = "1.0.188" 572 | source = "registry+https://github.com/rust-lang/crates.io-index" 573 | checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" 574 | dependencies = [ 575 | "proc-macro2", 576 | "quote", 577 | "syn 2.0.36", 578 | ] 579 | 580 | [[package]] 581 | name = "serde_json" 582 | version = "1.0.107" 583 | source = "registry+https://github.com/rust-lang/crates.io-index" 584 | checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" 585 | dependencies = [ 586 | "itoa", 587 | "ryu", 588 | "serde", 589 | ] 590 | 591 | [[package]] 592 | name = "serde_yaml" 593 | version = "0.9.25" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" 596 | dependencies = [ 597 | "indexmap 2.2.6", 598 | "itoa", 599 | "ryu", 600 | "serde", 601 | "unsafe-libyaml", 602 | ] 603 | 604 | [[package]] 605 | name = "shell-words" 606 | version = "1.1.0" 607 | source = "registry+https://github.com/rust-lang/crates.io-index" 608 | checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" 609 | 610 | [[package]] 611 | name = "std_prelude" 612 | version = "0.2.12" 613 | source = "registry+https://github.com/rust-lang/crates.io-index" 614 | checksum = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe" 615 | 616 | [[package]] 617 | name = "strsim" 618 | version = "0.11.1" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 621 | 622 | [[package]] 623 | name = "syn" 624 | version = "1.0.98" 625 | source = "registry+https://github.com/rust-lang/crates.io-index" 626 | checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 627 | dependencies = [ 628 | "proc-macro2", 629 | "quote", 630 | "unicode-ident", 631 | ] 632 | 633 | [[package]] 634 | name = "syn" 635 | version = "2.0.36" 636 | source = "registry+https://github.com/rust-lang/crates.io-index" 637 | checksum = "91e02e55d62894af2a08aca894c6577281f76769ba47c94d5756bec8ac6e7373" 638 | dependencies = [ 639 | "proc-macro2", 640 | "quote", 641 | "unicode-ident", 642 | ] 643 | 644 | [[package]] 645 | name = "syntect" 646 | version = "5.0.0" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "c6c454c27d9d7d9a84c7803aaa3c50cd088d2906fe3c6e42da3209aa623576a8" 649 | dependencies = [ 650 | "bincode", 651 | "bitflags", 652 | "fancy-regex", 653 | "flate2", 654 | "fnv", 655 | "lazy_static", 656 | "once_cell", 657 | "regex-syntax 0.6.27", 658 | "serde", 659 | "serde_derive", 660 | "serde_json", 661 | "thiserror", 662 | "walkdir", 663 | ] 664 | 665 | [[package]] 666 | name = "termcolor" 667 | version = "1.1.2" 668 | source = "registry+https://github.com/rust-lang/crates.io-index" 669 | checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" 670 | dependencies = [ 671 | "winapi-util", 672 | ] 673 | 674 | [[package]] 675 | name = "thiserror" 676 | version = "1.0.31" 677 | source = "registry+https://github.com/rust-lang/crates.io-index" 678 | checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" 679 | dependencies = [ 680 | "thiserror-impl", 681 | ] 682 | 683 | [[package]] 684 | name = "thiserror-impl" 685 | version = "1.0.31" 686 | source = "registry+https://github.com/rust-lang/crates.io-index" 687 | checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" 688 | dependencies = [ 689 | "proc-macro2", 690 | "quote", 691 | "syn 1.0.98", 692 | ] 693 | 694 | [[package]] 695 | name = "time" 696 | version = "0.3.28" 697 | source = "registry+https://github.com/rust-lang/crates.io-index" 698 | checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" 699 | dependencies = [ 700 | "deranged", 701 | "itoa", 702 | "serde", 703 | "time-core", 704 | "time-macros", 705 | ] 706 | 707 | [[package]] 708 | name = "time-core" 709 | version = "0.1.1" 710 | source = "registry+https://github.com/rust-lang/crates.io-index" 711 | checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" 712 | 713 | [[package]] 714 | name = "time-macros" 715 | version = "0.2.14" 716 | source = "registry+https://github.com/rust-lang/crates.io-index" 717 | checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" 718 | dependencies = [ 719 | "time-core", 720 | ] 721 | 722 | [[package]] 723 | name = "tinyvec" 724 | version = "0.3.4" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" 727 | 728 | [[package]] 729 | name = "unicode-bidi" 730 | version = "0.3.4" 731 | source = "registry+https://github.com/rust-lang/crates.io-index" 732 | checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" 733 | dependencies = [ 734 | "matches", 735 | ] 736 | 737 | [[package]] 738 | name = "unicode-ident" 739 | version = "1.0.2" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" 742 | 743 | [[package]] 744 | name = "unicode-normalization" 745 | version = "0.1.13" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" 748 | dependencies = [ 749 | "tinyvec", 750 | ] 751 | 752 | [[package]] 753 | name = "unicode-width" 754 | version = "0.1.10" 755 | source = "registry+https://github.com/rust-lang/crates.io-index" 756 | checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" 757 | 758 | [[package]] 759 | name = "unsafe-libyaml" 760 | version = "0.2.11" 761 | source = "registry+https://github.com/rust-lang/crates.io-index" 762 | checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" 763 | 764 | [[package]] 765 | name = "ureq" 766 | version = "2.9.6" 767 | source = "registry+https://github.com/rust-lang/crates.io-index" 768 | checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" 769 | dependencies = [ 770 | "base64", 771 | "log", 772 | "once_cell", 773 | "serde", 774 | "serde_json", 775 | "url", 776 | ] 777 | 778 | [[package]] 779 | name = "url" 780 | version = "2.1.1" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" 783 | dependencies = [ 784 | "idna", 785 | "matches", 786 | "percent-encoding", 787 | ] 788 | 789 | [[package]] 790 | name = "walkdir" 791 | version = "2.3.1" 792 | source = "registry+https://github.com/rust-lang/crates.io-index" 793 | checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" 794 | dependencies = [ 795 | "same-file", 796 | "winapi", 797 | "winapi-util", 798 | ] 799 | 800 | [[package]] 801 | name = "winapi" 802 | version = "0.3.9" 803 | source = "registry+https://github.com/rust-lang/crates.io-index" 804 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 805 | dependencies = [ 806 | "winapi-i686-pc-windows-gnu", 807 | "winapi-x86_64-pc-windows-gnu", 808 | ] 809 | 810 | [[package]] 811 | name = "winapi-i686-pc-windows-gnu" 812 | version = "0.4.0" 813 | source = "registry+https://github.com/rust-lang/crates.io-index" 814 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 815 | 816 | [[package]] 817 | name = "winapi-util" 818 | version = "0.1.5" 819 | source = "registry+https://github.com/rust-lang/crates.io-index" 820 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 821 | dependencies = [ 822 | "winapi", 823 | ] 824 | 825 | [[package]] 826 | name = "winapi-x86_64-pc-windows-gnu" 827 | version = "0.4.0" 828 | source = "registry+https://github.com/rust-lang/crates.io-index" 829 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 830 | 831 | [[package]] 832 | name = "windows-sys" 833 | version = "0.45.0" 834 | source = "registry+https://github.com/rust-lang/crates.io-index" 835 | checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 836 | dependencies = [ 837 | "windows-targets 0.42.2", 838 | ] 839 | 840 | [[package]] 841 | name = "windows-sys" 842 | version = "0.48.0" 843 | source = "registry+https://github.com/rust-lang/crates.io-index" 844 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 845 | dependencies = [ 846 | "windows-targets 0.48.5", 847 | ] 848 | 849 | [[package]] 850 | name = "windows-sys" 851 | version = "0.52.0" 852 | source = "registry+https://github.com/rust-lang/crates.io-index" 853 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 854 | dependencies = [ 855 | "windows-targets 0.52.4", 856 | ] 857 | 858 | [[package]] 859 | name = "windows-targets" 860 | version = "0.42.2" 861 | source = "registry+https://github.com/rust-lang/crates.io-index" 862 | checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 863 | dependencies = [ 864 | "windows_aarch64_gnullvm 0.42.2", 865 | "windows_aarch64_msvc 0.42.2", 866 | "windows_i686_gnu 0.42.2", 867 | "windows_i686_msvc 0.42.2", 868 | "windows_x86_64_gnu 0.42.2", 869 | "windows_x86_64_gnullvm 0.42.2", 870 | "windows_x86_64_msvc 0.42.2", 871 | ] 872 | 873 | [[package]] 874 | name = "windows-targets" 875 | version = "0.48.5" 876 | source = "registry+https://github.com/rust-lang/crates.io-index" 877 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 878 | dependencies = [ 879 | "windows_aarch64_gnullvm 0.48.5", 880 | "windows_aarch64_msvc 0.48.5", 881 | "windows_i686_gnu 0.48.5", 882 | "windows_i686_msvc 0.48.5", 883 | "windows_x86_64_gnu 0.48.5", 884 | "windows_x86_64_gnullvm 0.48.5", 885 | "windows_x86_64_msvc 0.48.5", 886 | ] 887 | 888 | [[package]] 889 | name = "windows-targets" 890 | version = "0.52.4" 891 | source = "registry+https://github.com/rust-lang/crates.io-index" 892 | checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" 893 | dependencies = [ 894 | "windows_aarch64_gnullvm 0.52.4", 895 | "windows_aarch64_msvc 0.52.4", 896 | "windows_i686_gnu 0.52.4", 897 | "windows_i686_msvc 0.52.4", 898 | "windows_x86_64_gnu 0.52.4", 899 | "windows_x86_64_gnullvm 0.52.4", 900 | "windows_x86_64_msvc 0.52.4", 901 | ] 902 | 903 | [[package]] 904 | name = "windows_aarch64_gnullvm" 905 | version = "0.42.2" 906 | source = "registry+https://github.com/rust-lang/crates.io-index" 907 | checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 908 | 909 | [[package]] 910 | name = "windows_aarch64_gnullvm" 911 | version = "0.48.5" 912 | source = "registry+https://github.com/rust-lang/crates.io-index" 913 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 914 | 915 | [[package]] 916 | name = "windows_aarch64_gnullvm" 917 | version = "0.52.4" 918 | source = "registry+https://github.com/rust-lang/crates.io-index" 919 | checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" 920 | 921 | [[package]] 922 | name = "windows_aarch64_msvc" 923 | version = "0.42.2" 924 | source = "registry+https://github.com/rust-lang/crates.io-index" 925 | checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 926 | 927 | [[package]] 928 | name = "windows_aarch64_msvc" 929 | version = "0.48.5" 930 | source = "registry+https://github.com/rust-lang/crates.io-index" 931 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 932 | 933 | [[package]] 934 | name = "windows_aarch64_msvc" 935 | version = "0.52.4" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" 938 | 939 | [[package]] 940 | name = "windows_i686_gnu" 941 | version = "0.42.2" 942 | source = "registry+https://github.com/rust-lang/crates.io-index" 943 | checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 944 | 945 | [[package]] 946 | name = "windows_i686_gnu" 947 | version = "0.48.5" 948 | source = "registry+https://github.com/rust-lang/crates.io-index" 949 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 950 | 951 | [[package]] 952 | name = "windows_i686_gnu" 953 | version = "0.52.4" 954 | source = "registry+https://github.com/rust-lang/crates.io-index" 955 | checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" 956 | 957 | [[package]] 958 | name = "windows_i686_msvc" 959 | version = "0.42.2" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 962 | 963 | [[package]] 964 | name = "windows_i686_msvc" 965 | version = "0.48.5" 966 | source = "registry+https://github.com/rust-lang/crates.io-index" 967 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 968 | 969 | [[package]] 970 | name = "windows_i686_msvc" 971 | version = "0.52.4" 972 | source = "registry+https://github.com/rust-lang/crates.io-index" 973 | checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" 974 | 975 | [[package]] 976 | name = "windows_x86_64_gnu" 977 | version = "0.42.2" 978 | source = "registry+https://github.com/rust-lang/crates.io-index" 979 | checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 980 | 981 | [[package]] 982 | name = "windows_x86_64_gnu" 983 | version = "0.48.5" 984 | source = "registry+https://github.com/rust-lang/crates.io-index" 985 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 986 | 987 | [[package]] 988 | name = "windows_x86_64_gnu" 989 | version = "0.52.4" 990 | source = "registry+https://github.com/rust-lang/crates.io-index" 991 | checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" 992 | 993 | [[package]] 994 | name = "windows_x86_64_gnullvm" 995 | version = "0.42.2" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 998 | 999 | [[package]] 1000 | name = "windows_x86_64_gnullvm" 1001 | version = "0.48.5" 1002 | source = "registry+https://github.com/rust-lang/crates.io-index" 1003 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1004 | 1005 | [[package]] 1006 | name = "windows_x86_64_gnullvm" 1007 | version = "0.52.4" 1008 | source = "registry+https://github.com/rust-lang/crates.io-index" 1009 | checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" 1010 | 1011 | [[package]] 1012 | name = "windows_x86_64_msvc" 1013 | version = "0.42.2" 1014 | source = "registry+https://github.com/rust-lang/crates.io-index" 1015 | checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 1016 | 1017 | [[package]] 1018 | name = "windows_x86_64_msvc" 1019 | version = "0.48.5" 1020 | source = "registry+https://github.com/rust-lang/crates.io-index" 1021 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1022 | 1023 | [[package]] 1024 | name = "windows_x86_64_msvc" 1025 | version = "0.52.4" 1026 | source = "registry+https://github.com/rust-lang/crates.io-index" 1027 | checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" 1028 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["pjmp"] 3 | categories = ["command-line-utilities"] 4 | description = """ 5 | Highly readable supplement to man pages. 6 | Shows simple, concise examples for commands. 7 | """ 8 | edition = "2021" 9 | homepage = "https://github.com/pombadev/bropages" 10 | keywords = ["bro", "bropages", "tldr", "cheatsheet"] 11 | license = "MIT" 12 | name = "bropages" 13 | readme = "README.md" 14 | repository = "https://github.com/pombadev/bropages" 15 | resolver = "2" 16 | version = "1.5.0" 17 | 18 | [dependencies] 19 | bat = {version = "0.24.0", default-features = false, features = ["paging", "regex-fancy"]} 20 | clap = {version = "4.5.4", default-features = false, features = [ 21 | "error-context", 22 | "help", 23 | "std", 24 | "suggestions", 25 | "usage", 26 | ]} 27 | ureq = {version = "2.9.6", default-features = false, features = ["json"]} 28 | 29 | [[bin]] 30 | name = "bro" 31 | path = "src/main.rs" 32 | 33 | [profile.release] 34 | lto = true 35 | opt-level = 3 36 | panic = 'abort' 37 | strip = true 38 | -------------------------------------------------------------------------------- /LICENSE-MIT.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 pjmp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | bropages (bro) 2 | ------------ 3 | A CLI to interact with [bropages.org](http://bropages.org). 4 | 5 | Highly readable supplement to man pages. Shows simple, concise examples for commands with syntax highlighting. 6 | 7 | [![Crates.io](https://img.shields.io/crates/v/bropages)](https://crates.io/crates/bropages) 8 | ![License](https://img.shields.io/crates/l/bropages) 9 | 10 | ### Screencast 11 | 12 | [![A screenshot](./screencast.gif)](./screencast.gif) 13 | 14 | ### Installation 15 | 16 | The binary name for bropages is `bro`. 17 | 18 | Currently `bropages` is only available through `cargo`. 19 | ``` 20 | cargo install bropages 21 | ``` 22 | 23 | ### Available options 24 | ``` 25 | USAGE: 26 | bro [OPTIONS] 27 | 28 | ARGS: 29 | 30 | Command to lookup 31 | 32 | OPTIONS: 33 | -h, --help 34 | Print help information 35 | 36 | --list-themes 37 | Display a list of supported themes for syntax highlighting. 38 | 39 | --no-paging 40 | Disable piping of the output through a pager 41 | 42 | -s, --search 43 | Search if provided query exist in the database 44 | This searches for entries in the http://bropages.org database 45 | 46 | -t, --theme 47 | Set the theme for syntax highlighting, default is `OneHalfDark`. Use '--list-themes' to 48 | see all available themes. 49 | 50 | [possible values: 1337, Coldark-Cold, Coldark-Dark, DarkNeon, Dracula, GitHub, "Monokai 51 | Extended", "Monokai Extended Bright", "Monokai Extended Light", "Monokai Extended 52 | Origin", Nord, OneHalfDark, OneHalfLight, "Solarized (dark)", "Solarized (light)", 53 | "Sublime Snazzy", TwoDark, "Visual Studio Dark+", ansi, base16, base16-256, 54 | gruvbox-dark, gruvbox-light, zenburn] 55 | 56 | -V, --version 57 | Print version information 58 | ``` 59 | 60 | ### Note 61 | 62 | - This is an unofficial rust port of [ruby bropages](https://rubygems.org/gems/bropages). 63 | - I don't have any intentions to add the `add`, `no`/`...no` or `thanks` commands. 64 | 65 | ### TODO 66 | - [ ] Cache results ? 67 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | env, fs, 3 | path::Path, 4 | process::{Command, Stdio}, 5 | }; 6 | 7 | fn main() { 8 | let mut version = format!("v{}", env!("CARGO_PKG_VERSION")); 9 | 10 | let out = Command::new("git") 11 | .args(["rev-parse", "--short", "HEAD"]) 12 | .stdout(Stdio::piped()) 13 | .output() 14 | .ok() 15 | .and_then(|output| String::from_utf8(output.stdout).ok()) 16 | .unwrap_or_default(); 17 | 18 | if !out.is_empty() { 19 | version.push('+'); 20 | version.push_str(out.trim()); 21 | } 22 | 23 | fs::write( 24 | Path::new(&env::var("OUT_DIR").expect("OUT_DIR to be defined")).join("version"), 25 | &version, 26 | ) 27 | .unwrap_or_else(|err| panic!("create version file with: {version} failed because: {err}")); 28 | } 29 | -------------------------------------------------------------------------------- /screencast.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pombadev/bropages/ad467aa352bdcb1d7c92c815a9c7ff6c8ba19245/screencast.gif -------------------------------------------------------------------------------- /src/bro.rs: -------------------------------------------------------------------------------- 1 | use std::env::consts; 2 | use std::{env, error::Error, process}; 3 | 4 | use bat::{PagingMode, PrettyPrinter}; 5 | use clap::{Arg, ArgAction, Command}; 6 | use ureq::serde::{de::DeserializeOwned, Deserialize, Serialize}; 7 | 8 | const VERSION_STRING: &str = include_str!(concat!(env!("OUT_DIR"), "/version")); 9 | 10 | // snippets taken from: https://google.github.io/styleguide/shellguide.html 11 | const BASH_SYNTAX_DEMO: &str = r#"#!/usr/bin/env sh 12 | 13 | # All fits on one line 14 | command1 | command2 15 | 16 | # Long commands 17 | command1 \ 18 | | command2 \ 19 | | command3 \ 20 | | command4 21 | 22 | # log to stderr 23 | err() { 24 | echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2 25 | } 26 | 27 | if ! do_something; then 28 | err "Unable to do_something" 29 | exit 1 30 | fi 31 | "#; 32 | 33 | #[derive(Serialize, Deserialize)] 34 | #[serde(crate = "ureq::serde")] 35 | struct BroLookupResponse { 36 | cmd: String, 37 | msg: String, 38 | up: i32, 39 | } 40 | 41 | #[derive(Serialize, Deserialize)] 42 | #[serde(crate = "ureq::serde")] 43 | struct BroSearchResponse { 44 | cmd: String, 45 | } 46 | 47 | pub struct Cli { 48 | list_themes: bool, 49 | no_paging: bool, 50 | query: String, 51 | search: bool, 52 | theme: String, 53 | themes: Vec, 54 | } 55 | 56 | impl Cli { 57 | pub fn run() { 58 | let app = Self::new(); 59 | 60 | if app.list_themes { 61 | return app.list_themes(); 62 | } 63 | 64 | if app.search { 65 | app.search(); 66 | } else { 67 | app.lookup(); 68 | } 69 | } 70 | 71 | fn new() -> Self { 72 | let themes = bat::assets::HighlightingAssets::from_binary(); 73 | 74 | let themes = themes.themes().collect::>(); 75 | 76 | let cmd = Command::new(env!("CARGO_PKG_NAME")) 77 | .version(VERSION_STRING) 78 | .about(env!("CARGO_PKG_DESCRIPTION")) 79 | .arg_required_else_help(true) 80 | .args(&[ 81 | Arg::new("query") 82 | .required(true) 83 | .action(ArgAction::Set) 84 | .help("Command to lookup"), 85 | 86 | Arg::new("list-themes") 87 | .long("list-themes") 88 | .action(ArgAction::SetTrue) 89 | .help("Display a list of supported themes for syntax highlighting.") 90 | .conflicts_with_all(["theme", "search", "query", "no-paging"]), 91 | 92 | Arg::new("theme") 93 | .long("theme") 94 | .short('t') 95 | .action(ArgAction::Set) 96 | // .value_parser(&themes[..]) 97 | .help("Set the theme for syntax highlighting, default is `OneHalfDark`. Use '--list-themes' to see all available themes.") 98 | .conflicts_with_all(["list-themes"]), 99 | 100 | Arg::new("search") 101 | .short('s') 102 | .long("search") 103 | .action(ArgAction::SetTrue) 104 | .help("Search if provided query exist in the database") 105 | .long_help("Search if provided query exist in the database\nThis searches for entries in the http://bropages.org database"), 106 | 107 | Arg::new("no-paging") 108 | .long("no-paging") 109 | .action(ArgAction::SetTrue) 110 | .help("Disable piping of the output through a pager") 111 | ]).get_matches(); 112 | 113 | let theme = match cmd.get_one::("theme") { 114 | Some(theme) => theme.clone(), 115 | None => "OneHalfDark".into(), 116 | }; 117 | 118 | let query = match cmd.get_one::("query") { 119 | Some(query) => query.clone(), 120 | None => String::new(), 121 | }; 122 | 123 | let list_themes = cmd.get_one::("list-themes").unwrap_or(&false); 124 | let no_paging = cmd.get_one::("no-paging").unwrap_or(&false); 125 | let search = cmd.get_one::("search").unwrap_or(&false); 126 | 127 | Self { 128 | theme, 129 | query, 130 | list_themes: *list_themes, 131 | no_paging: *no_paging, 132 | search: *search, 133 | themes: themes.iter().copied().map(String::from).collect::>(), 134 | } 135 | } 136 | 137 | fn format_to_string(list: &[String]) -> String { 138 | list.iter().fold(String::new(), |mut init, current| { 139 | let splits = current.split('\n'); 140 | 141 | let next = splits 142 | .filter_map(|item| { 143 | if item.is_empty() { 144 | return None; 145 | } 146 | 147 | let inner_next = if item.starts_with('#') { 148 | format!("\n{item}") 149 | } else { 150 | format!("\n{item}\n") 151 | }; 152 | 153 | Some(inner_next) 154 | }) 155 | .collect::(); 156 | 157 | init.push_str(next.as_str()); 158 | 159 | init 160 | }) 161 | } 162 | 163 | fn eprint_and_exit(msg: &str) { 164 | eprintln!("Unable to find because of:\n - {msg}"); 165 | process::exit(1); 166 | } 167 | 168 | fn fetch(path: &str) -> Result, Box> { 169 | let host = option_env!("BROPAGES_BASE_URL").unwrap_or_else(|| "http://bropages.org"); 170 | 171 | let url = format!("{host}{path}"); 172 | 173 | ureq::get(&url) 174 | .set( 175 | "User-Agent", 176 | format!( 177 | "{}/{} ({}, {}) ureq/2.7.1", 178 | env!("CARGO_PKG_NAME"), 179 | env!("CARGO_PKG_VERSION"), 180 | consts::OS, 181 | consts::ARCH, 182 | ) 183 | .as_str(), 184 | ) 185 | .call()? 186 | .into_json::>() 187 | .map_err(Into::into) 188 | } 189 | 190 | fn lookup(&self) { 191 | match Self::fetch::(&format!("/{}.json", &self.query)) { 192 | Ok(mut response) => { 193 | response.sort_by(|a, b| a.up.cmp(&b.up)); 194 | 195 | let list = response 196 | .iter() 197 | .map(|item| item.msg.clone()) 198 | .collect::>(); 199 | 200 | let snippet = Self::format_to_string(&list); 201 | 202 | self.print(snippet.as_bytes()); 203 | } 204 | Err(err) => Self::eprint_and_exit(&err.to_string()), 205 | }; 206 | } 207 | 208 | fn search(&self) { 209 | match Self::fetch::(&format!("/search/{}.json", &self.query)) { 210 | Ok(res) => { 211 | let list = res.iter().map(|item| item.cmd.clone()).collect::>(); 212 | 213 | let total = list.len(); 214 | 215 | let snippet = format!( 216 | "# Total {} matches for the term '{}':\n{}", 217 | total, 218 | &self.query, 219 | Self::format_to_string(&list) 220 | ); 221 | 222 | self.print(snippet.as_bytes()); 223 | } 224 | Err(err) => Self::eprint_and_exit(&err.to_string()), 225 | }; 226 | } 227 | 228 | fn print(&self, snippet: &[u8]) { 229 | let paging = if self.no_paging { 230 | PagingMode::Never 231 | } else { 232 | PagingMode::QuitIfOneScreen 233 | }; 234 | 235 | let displayed = PrettyPrinter::new() 236 | .input_from_bytes(snippet) 237 | .line_numbers(true) 238 | .language("bash") 239 | .theme(&self.theme) 240 | .colored_output(env::var_os("NO_COLOR").is_none()) 241 | .paging_mode(paging) 242 | .print() 243 | .unwrap_or(false); 244 | 245 | if !displayed { 246 | eprintln!("Warning: syntax highlight failed."); 247 | println!("{}", String::from_utf8_lossy(snippet)); 248 | } 249 | } 250 | 251 | fn list_themes(&self) { 252 | let mut printer = PrettyPrinter::new(); 253 | 254 | for theme in &self.themes { 255 | println!("Theme: {theme}"); 256 | let _ = printer 257 | .input_from_bytes(BASH_SYNTAX_DEMO.as_bytes()) 258 | .colored_output(true) 259 | .language("bash") 260 | .theme(theme) 261 | .grid(true) 262 | .line_numbers(true) 263 | .print(); 264 | 265 | println!(); 266 | } 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod bro; 2 | 3 | fn main() { 4 | bro::Cli::run(); 5 | } 6 | --------------------------------------------------------------------------------