1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
//! A [`cargo` subcommand](https://github.com/rust-lang/cargo/wiki/Third-party-cargo-subcommands) for checking and applying
//! updates to installed executables
//!
//! # Special thanks
//!
//! To all who support further development on [Patreon](https://patreon.com/nabijaczleweli), in particular:
//!
//!   * ThePhD
//!   * Embark Studios
//!
//! # Library doc
//!
//! This library is used by `cargo-update` itself for all its function and is therefore contains all necessary functions.
//!
//! ## Example
//!
//! See the [`src/main.rs`](https://github.com/nabijaczleweli/cargo-update/blob/master/src/main.rs) file in the git repository.
//!
//! # Executable manpage
//!
//! ## SYNOPSIS
//!
//! [`cargo install-update`](https://github.com/nabijaczleweli/cargo-update) [OPTIONS] [PACKAGE...]
//!
//! ## DESCRIPTION
//!
//!
//! Cargo subcommand for checking and applying updates to installed executables.
//!
//! This was mostly built out of a frustration with periodically checking for
//! updates for my cargo-installed executables, which was long and boring.
//!
//! Updates packages from the main repository and git repositories.
//!
//! See
//! [cargo-install-update-config(1)](https://rawcdn.githack.com/nabijaczleweli/cargo-update/man/cargo-install-update-config.1.html)
//! for further configuring updates.
//!
//! The `CARGO_INSTALL_OPTS` environment variable can be set,
//! containing options to forward to the end of `cargo install` invocations'
//! argument lists.
//! Note, that
//! [cargo-install-update-config(1)](https://rawcdn.githack.com/nabijaczleweli/cargo-update/man/cargo-install-update-config.1.html)
//! is preferred in the general case.
//!
//! Exit values and possible errors:
//!
//! ```text
//! -1 - cargo subprocess was terminated by a signal (Linux-only)
//! 1  - option parsing error
//! 2  - registry repository error
//! X  - bubbled-up cargo install exit value
//! ```
//!
//! ## OPTIONS
//!
//! -a --all
//!
//! ```text
//! Update all currently installed executables.
//!
//! Required if list of packages not given.
//! ```
//!
//! [PACKAGE...]
//!
//! ```text
//! List of packages to update in the [(registry_url):]package_name[:version] format.
//!
//! Registry defaults to the default crates.io registry,
//! and can be a name from ~/.cargo/config.
//!
//! If specified in addition to --all,
//! will add the specified packages to the update list
//! (useful, e.g., in conjunction with --allow-no-update).
//!
//! Required if --all not given.
//! ```
//!
//! -l --list
//!
//! ```text
//! Don't update any packages, just list them.
//!
//! If PACKAGE is empty, act as if --all was specified.
//! ```
//!
//! -f --force
//!
//! ```text
//! Update all packages, regardless of whether they need to be version-wise.
//! ```
//!
//! -i --allow-no-update
//!
//! ```text
//! Allow to fresh install packages passed as PACKAGE argument.
//!
//! This is useful, for example, in pairing with cargo-install-update-config(1).
//!
//! Off by default.
//! ```
//!
//! -g --git
//!
//! ```text
//! Also update git-originating packages.
//!
//! Off by default, because it's expensive.
//! ```
//!
//! -q --quiet
//!
//! ```text
//! Don't print status messages to stdout
//! and pass down --quiet to cargo subprocesses.
//! ```
//!
//! -s --filter <PACKAGE_FILTER>...
//!
//! ```text
//! Only consider packages matching all filters.
//!
//! PACKAGE_FILTER is in the form "key=value", where key is any of:
//!   - "toolchain": the package must be configured to be compiled with
//!                  the specified toolchain via cargo-install-update-config(1).
//! ```
//!
//! -c --cargo-dir <CARGO_DIR>
//!
//! ```text
//! Set the directory containing cargo metadata.
//!
//! Required. Default: "$CARGO_HOME", then "$HOME/.cargo", otherwise manual.
//! ```
//!
//! -t --temp-dir <TEMP_DIR>
//!
//! ```text
//! Set the directory in which to clone git repositories.
//!
//! Adjoined with "cargo-update" as last segment.
//!
//! Required. Default: system temp, otherwise manual.
//! ```
//!
//! ## EXAMPLES
//!
//! `cargo install-update -a`
//!
//! ```text
//! Update all installed packages.
//!
//! Example output:
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!
//!   Package         Installed  Latest   Needs update
//!   checksums       v0.5.0     v0.5.2   Yes
//!   treesize        v0.2.0     v0.2.1   Yes
//!   cargo-count     v0.2.2     v0.2.2   No
//!   cargo-graph     v0.3.0     v0.3.0   No
//!   cargo-outdated  v0.2.0     v0.2.0   No
//!   identicon       v0.1.1     v0.1.1   No
//!   racer           v1.2.10    v1.2.10  No
//!   rustfmt         v0.6.2     v0.6.2   No
//!
//!   Updating checksums
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading checksums v0.5.2
//!      [...]
//!      Compiling checksums v0.5.2
//!       Finished release [optimized] target(s) in 95.2 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\checksums.exe
//!
//!   Updating treesize
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading treesize v0.2.1
//!      [...]
//!      Compiling treesize v0.2.1
//!       Finished release [optimized] target(s) in 76.77 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\treesize.exe
//!
//!   Updated 2 packages.
//! ```
//!
//! `cargo install-update` *racer treesize cargo-cln*
//!
//! ```text
//! Only consider racer, treesize and cargo-cln for updates.
//! Since cargo-cln is not installed, it'll be ignored.
//!
//!  Example output:
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!
//!   Package   Installed  Latest   Needs update
//!   treesize  v0.2.0     v0.2.1   Yes
//!   racer     v1.2.10    v1.2.10  No
//!
//!   Updating treesize
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading treesize v0.2.1
//!      [...]
//!      Compiling treesize v0.2.1
//!       Finished release [optimized] target(s) in 76.77 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\treesize.exe
//!
//!   Updated 1 package.
//! ```
//!
//! `cargo install-update -al`
//!
//! ```text
//! List all installed packages, don't update any.
//!
//! Example output:
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!
//!   Package         Installed  Latest   Needs update
//!   checksums       v0.5.0     v0.5.2   Yes
//!   treesize        v0.2.0     v0.2.1   Yes
//!   cargo-count     v0.2.2     v0.2.2   No
//!   cargo-graph     v0.3.0     v0.3.0   No
//!   cargo-outdated  v0.2.0     v0.2.0   No
//!   identicon       v0.1.1     v0.1.1   No
//!   racer           v1.2.10    v1.2.10  No
//!   rustfmt         v0.6.2     v0.6.2   No
//! ```
//!
//! `cargo install-update -af`
//!
//! ```text
//! Update all installed packages.
//! Example output:
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!
//!   Package   Installed  Latest   Needs update
//!   treesize  v0.2.0     v0.2.1   Yes
//!   racer     v1.2.10    v1.2.10  No
//!
//!   Updating racer
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading racer v1.2.10
//!      [...]
//!      Compiling racer v1.2.10
//!       Finished release [optimized] target(s) in 51.43 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\racer.exe
//!
//!   Updating clippy
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading clippy v0.0.99
//!      [...]
//!      Compiling clippy v0.0.99
//!      [...]
//!   error: failed to compile `clippy v0.0.99`
//!
//!   Updating treesize
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading treesize v0.2.1
//!      [...]
//!      Compiling treesize v0.2.1
//!       Finished release [optimized] target(s) in 76.77 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\treesize.exe
//!
//!   Updating clippy_lints
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!   error: specified package has no binaries
//!
//!   Updated 2 packages.
//!   Failed to update clippy, clippy_lints.
//! ```
//!
//! `cargo install-update -i checksums rustfmt treesize`
//!
//! ```text
//! Install specified packages, their installation status notwithstanding
//!
//! Example output:
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!
//!   Package    Installed  Latest   Needs update
//!   checksums             v0.5.2   Yes
//!   treesize   v0.2.0     v0.2.1   Yes
//!   rustfmt    v0.6.2     v0.6.2   No
//!
//!   Installing checksums
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading checksums v0.5.2
//!      [...]
//!      Compiling checksums v0.5.2
//!       Finished release [optimized] target(s) in 95.2 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\checksums.exe
//!
//!   Updating treesize
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading treesize v0.2.1
//!      [...]
//!      Compiling treesize v0.2.1
//!       Finished release [optimized] target(s) in 76.77 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\treesize.exe
//!
//!   Updated 2 packages.
//! ```
//!
//! `cargo install-update -i (file:///usr/local/share/cargo):zram-generator:0.1.1`
//!
//! ```text
//! Install zram-generator from a local repository in /usr/local/share/cargo
//! (but a remote one or a short name will work just as well), at most version 0.1.1.
//!
//!  Example output:
//!       Updating registry `file:///usr/local/share/cargo`
//!
//!   Package         Installed  Latest   Needs update
//!   zram-generator             v0.1.1   Yes
//!
//!   Installing zram-generator
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading zram-generator v0.1.1
//!      [...]
//!      Compiling zram-generator v0.1.1
//!       Finished release [optimized] target(s) in 21.62 secs
//!     Installing /home/nabijaczleweli/.cargo/bin/zram-generator
//!      Installed package `zram-generator v0.1.1` (executable `zram-generator`)
//!
//!   Updated 1 package.
//! ```
//!
//! `cargo install-update -ag`
//!
//! ```text
//! Update all installed packages, including ones from git.
//!
//! Example output:
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!
//!   Package         Installed  Latest   Needs update
//!   checksums       v0.5.0     v0.5.2   Yes
//!   cargo-count     v0.2.2     v0.2.2   No
//!
//!   Updating checksums
//!       Updating registry `https://github.com/rust-lang/crates.io-index`
//!      Downloading checksums v0.5.2
//!      [...]
//!      Compiling checksums v0.5.2
//!       Finished release [optimized] target(s) in 95.2 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\checksums.exe
//!
//!   Updated 1 package.
//!
//!   Package                Installed  Latest   Needs update
//!   alacritty              eb231b3    5f78857  Yes
//!   chattium-oxide-client  108a7b9    108a7b9  No
//!
//!   Updating alacritty from https://github.com/jwilm/alacritty
//!       Updating git repository `https://github.com/jwilm/alacritty`
//!      Installing alacritty v0.1.0 (https://github.com/jwilm/alacritty#5f788574)
//!      [...]
//!      Compiling alacritty v0.1.0
//!       Finished release [optimized] target(s) in 127.6 secs
//!      Replacing D:\Users\nabijaczleweli\.cargo\bin\alacritty.exe
//!
//!   Updated 1 package.
//! ```


#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]


#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate lazy_static;
extern crate array_tool;
extern crate semver;
extern crate regex;
extern crate git2;
#[macro_use]
extern crate clap;
extern crate dirs;
extern crate toml;
extern crate json;
extern crate hex;
extern crate url;

mod options;

pub mod ops;

pub use options::{ConfigOptions, Options};