├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md └── src └── main.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /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 = "ansi_term" 7 | version = "0.11.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" 10 | dependencies = [ 11 | "winapi", 12 | ] 13 | 14 | [[package]] 15 | name = "anyhow" 16 | version = "1.0.44" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" 19 | 20 | [[package]] 21 | name = "atty" 22 | version = "0.2.14" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 25 | dependencies = [ 26 | "hermit-abi", 27 | "libc", 28 | "winapi", 29 | ] 30 | 31 | [[package]] 32 | name = "bitflags" 33 | version = "1.3.2" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 36 | 37 | [[package]] 38 | name = "camino" 39 | version = "1.0.5" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "52d74260d9bf6944e2208aa46841b4b8f0d7ffc0849a06837b2f510337f86b2b" 42 | dependencies = [ 43 | "serde", 44 | ] 45 | 46 | [[package]] 47 | name = "cargo-platform" 48 | version = "0.1.2" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" 51 | dependencies = [ 52 | "serde", 53 | ] 54 | 55 | [[package]] 56 | name = "cargo-roogle" 57 | version = "0.1.0" 58 | dependencies = [ 59 | "anyhow", 60 | "cargo_metadata", 61 | "structopt", 62 | "tempfile", 63 | ] 64 | 65 | [[package]] 66 | name = "cargo_metadata" 67 | version = "0.14.1" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "ba2ae6de944143141f6155a473a6b02f66c7c3f9f47316f802f80204ebfe6e12" 70 | dependencies = [ 71 | "camino", 72 | "cargo-platform", 73 | "semver", 74 | "serde", 75 | "serde_json", 76 | ] 77 | 78 | [[package]] 79 | name = "cfg-if" 80 | version = "1.0.0" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 83 | 84 | [[package]] 85 | name = "clap" 86 | version = "2.33.3" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" 89 | dependencies = [ 90 | "ansi_term", 91 | "atty", 92 | "bitflags", 93 | "strsim", 94 | "textwrap", 95 | "unicode-width", 96 | "vec_map", 97 | ] 98 | 99 | [[package]] 100 | name = "getrandom" 101 | version = "0.2.3" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" 104 | dependencies = [ 105 | "cfg-if", 106 | "libc", 107 | "wasi", 108 | ] 109 | 110 | [[package]] 111 | name = "heck" 112 | version = "0.3.3" 113 | source = "registry+https://github.com/rust-lang/crates.io-index" 114 | checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 115 | dependencies = [ 116 | "unicode-segmentation", 117 | ] 118 | 119 | [[package]] 120 | name = "hermit-abi" 121 | version = "0.1.19" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 124 | dependencies = [ 125 | "libc", 126 | ] 127 | 128 | [[package]] 129 | name = "itoa" 130 | version = "0.4.8" 131 | source = "registry+https://github.com/rust-lang/crates.io-index" 132 | checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" 133 | 134 | [[package]] 135 | name = "lazy_static" 136 | version = "1.4.0" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 139 | 140 | [[package]] 141 | name = "libc" 142 | version = "0.2.106" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673" 145 | 146 | [[package]] 147 | name = "ppv-lite86" 148 | version = "0.2.15" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" 151 | 152 | [[package]] 153 | name = "proc-macro-error" 154 | version = "1.0.4" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 157 | dependencies = [ 158 | "proc-macro-error-attr", 159 | "proc-macro2", 160 | "quote", 161 | "syn", 162 | "version_check", 163 | ] 164 | 165 | [[package]] 166 | name = "proc-macro-error-attr" 167 | version = "1.0.4" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 170 | dependencies = [ 171 | "proc-macro2", 172 | "quote", 173 | "version_check", 174 | ] 175 | 176 | [[package]] 177 | name = "proc-macro2" 178 | version = "1.0.32" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" 181 | dependencies = [ 182 | "unicode-xid", 183 | ] 184 | 185 | [[package]] 186 | name = "quote" 187 | version = "1.0.10" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" 190 | dependencies = [ 191 | "proc-macro2", 192 | ] 193 | 194 | [[package]] 195 | name = "rand" 196 | version = "0.8.4" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" 199 | dependencies = [ 200 | "libc", 201 | "rand_chacha", 202 | "rand_core", 203 | "rand_hc", 204 | ] 205 | 206 | [[package]] 207 | name = "rand_chacha" 208 | version = "0.3.1" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 211 | dependencies = [ 212 | "ppv-lite86", 213 | "rand_core", 214 | ] 215 | 216 | [[package]] 217 | name = "rand_core" 218 | version = "0.6.3" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 221 | dependencies = [ 222 | "getrandom", 223 | ] 224 | 225 | [[package]] 226 | name = "rand_hc" 227 | version = "0.3.1" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" 230 | dependencies = [ 231 | "rand_core", 232 | ] 233 | 234 | [[package]] 235 | name = "redox_syscall" 236 | version = "0.2.10" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" 239 | dependencies = [ 240 | "bitflags", 241 | ] 242 | 243 | [[package]] 244 | name = "remove_dir_all" 245 | version = "0.5.3" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 248 | dependencies = [ 249 | "winapi", 250 | ] 251 | 252 | [[package]] 253 | name = "ryu" 254 | version = "1.0.5" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" 257 | 258 | [[package]] 259 | name = "semver" 260 | version = "1.0.4" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" 263 | dependencies = [ 264 | "serde", 265 | ] 266 | 267 | [[package]] 268 | name = "serde" 269 | version = "1.0.130" 270 | source = "registry+https://github.com/rust-lang/crates.io-index" 271 | checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" 272 | dependencies = [ 273 | "serde_derive", 274 | ] 275 | 276 | [[package]] 277 | name = "serde_derive" 278 | version = "1.0.130" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" 281 | dependencies = [ 282 | "proc-macro2", 283 | "quote", 284 | "syn", 285 | ] 286 | 287 | [[package]] 288 | name = "serde_json" 289 | version = "1.0.68" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" 292 | dependencies = [ 293 | "itoa", 294 | "ryu", 295 | "serde", 296 | ] 297 | 298 | [[package]] 299 | name = "strsim" 300 | version = "0.8.0" 301 | source = "registry+https://github.com/rust-lang/crates.io-index" 302 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 303 | 304 | [[package]] 305 | name = "structopt" 306 | version = "0.3.25" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" 309 | dependencies = [ 310 | "clap", 311 | "lazy_static", 312 | "structopt-derive", 313 | ] 314 | 315 | [[package]] 316 | name = "structopt-derive" 317 | version = "0.4.18" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" 320 | dependencies = [ 321 | "heck", 322 | "proc-macro-error", 323 | "proc-macro2", 324 | "quote", 325 | "syn", 326 | ] 327 | 328 | [[package]] 329 | name = "syn" 330 | version = "1.0.81" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" 333 | dependencies = [ 334 | "proc-macro2", 335 | "quote", 336 | "unicode-xid", 337 | ] 338 | 339 | [[package]] 340 | name = "tempfile" 341 | version = "3.2.0" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" 344 | dependencies = [ 345 | "cfg-if", 346 | "libc", 347 | "rand", 348 | "redox_syscall", 349 | "remove_dir_all", 350 | "winapi", 351 | ] 352 | 353 | [[package]] 354 | name = "textwrap" 355 | version = "0.11.0" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 358 | dependencies = [ 359 | "unicode-width", 360 | ] 361 | 362 | [[package]] 363 | name = "unicode-segmentation" 364 | version = "1.8.0" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" 367 | 368 | [[package]] 369 | name = "unicode-width" 370 | version = "0.1.9" 371 | source = "registry+https://github.com/rust-lang/crates.io-index" 372 | checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" 373 | 374 | [[package]] 375 | name = "unicode-xid" 376 | version = "0.2.2" 377 | source = "registry+https://github.com/rust-lang/crates.io-index" 378 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 379 | 380 | [[package]] 381 | name = "vec_map" 382 | version = "0.8.2" 383 | source = "registry+https://github.com/rust-lang/crates.io-index" 384 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 385 | 386 | [[package]] 387 | name = "version_check" 388 | version = "0.9.3" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" 391 | 392 | [[package]] 393 | name = "wasi" 394 | version = "0.10.2+wasi-snapshot-preview1" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 397 | 398 | [[package]] 399 | name = "winapi" 400 | version = "0.3.9" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 403 | dependencies = [ 404 | "winapi-i686-pc-windows-gnu", 405 | "winapi-x86_64-pc-windows-gnu", 406 | ] 407 | 408 | [[package]] 409 | name = "winapi-i686-pc-windows-gnu" 410 | version = "0.4.0" 411 | source = "registry+https://github.com/rust-lang/crates.io-index" 412 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 413 | 414 | [[package]] 415 | name = "winapi-x86_64-pc-windows-gnu" 416 | version = "0.4.0" 417 | source = "registry+https://github.com/rust-lang/crates.io-index" 418 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 419 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cargo-roogle" 3 | version = "0.1.0" 4 | authors = ["Hirochika Matsumoto "] 5 | edition = "2021" 6 | description = "A Cargo subcommand to run Roogle on local crates" 7 | readme = "README.md" 8 | repository = "https://github.com/roogle-rs/cargo-roogle" 9 | license = "MIT OR Apache-2.0" 10 | 11 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 12 | 13 | [dependencies] 14 | anyhow = "1.0" 15 | cargo_metadata = "0.14" 16 | structopt = "0.3" 17 | tempfile = "3.2" 18 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Hirochika Matsumoto 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 | # cargo-roogle 2 | A Cargo subcommand to run [Roogle](https://github.com/hkmatsumoto/roogle) on local crates. 3 | 4 | # Installation 5 | ```sh 6 | $ cargo install roogle 7 | $ cargo install cargo-roogle 8 | ``` 9 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::{self, create_dir_all}; 2 | use std::process; 3 | 4 | use anyhow::{Context, Result}; 5 | use cargo_metadata::MetadataCommand; 6 | use structopt::StructOpt; 7 | 8 | #[derive(Debug, StructOpt)] 9 | #[structopt(bin_name = "cargo")] 10 | enum Command { 11 | Roogle(Opt), 12 | } 13 | 14 | #[derive(Debug, StructOpt)] 15 | struct Opt {} 16 | 17 | fn build(_: &Opt) -> Result<()> { 18 | process::Command::new("cargo") 19 | .args(&[ 20 | "+nightly", 21 | "rustdoc", 22 | "--", 23 | "--output-format=json", 24 | "-Z", 25 | "unstable-options", 26 | ]) 27 | .spawn() 28 | .context("failed to build search index using `rustdoc`")? 29 | .wait()?; 30 | 31 | let metadata = MetadataCommand::new() 32 | .no_deps() 33 | .exec() 34 | .context("failed to get crate's metadata")?; 35 | let members = metadata 36 | .packages 37 | .iter() 38 | .filter(|p| metadata.workspace_members.contains(&p.id)) 39 | .map(|p| &p.name); 40 | 41 | create_dir_all("target/roogle/crate").context("failed create `crate` directory")?; 42 | for member in members { 43 | fs::rename( 44 | format!("target/doc/{}.json", member), 45 | format!("target/roogle/crate/{}.json", member), 46 | ) 47 | .context("failed to store crate's index to index folder")?; 48 | } 49 | 50 | Ok(()) 51 | } 52 | 53 | fn main() -> Result<()> { 54 | let Command::Roogle(opt) = Command::from_args(); 55 | build(&opt)?; 56 | 57 | process::Command::new("roogle") 58 | .args(&["--index", "target/roogle"]) 59 | .spawn() 60 | .context("failed to start server")? 61 | .wait()?; 62 | 63 | Ok(()) 64 | } 65 | --------------------------------------------------------------------------------