@@ -25,8 +25,13 @@ use crate::util::IntoUrl;
25
25
use crate :: util:: { paths, validate_package_name} ;
26
26
use crate :: version;
27
27
28
+ /// Registry settings loaded from config files.
29
+ ///
30
+ /// This is loaded based on the `--registry` flag and the config settings.
28
31
pub struct RegistryConfig {
32
+ /// The index URL. If `None`, use crates.io.
29
33
pub index : Option < String > ,
34
+ /// The authentication token.
30
35
pub token : Option < String > ,
31
36
}
32
37
@@ -316,10 +321,15 @@ fn transmit(
316
321
}
317
322
}
318
323
324
+ /// Returns the index and token from the config file for the given registry.
325
+ ///
326
+ /// `registry` is typically the registry specified on the command-line. If
327
+ /// `None`, returns the default index.
319
328
pub fn registry_configuration (
320
329
config : & Config ,
321
330
registry : Option < String > ,
322
331
) -> CargoResult < RegistryConfig > {
332
+ // `registry.default` is handled in command-line parsing.
323
333
let ( index, token) = match registry {
324
334
Some ( registry) => {
325
335
validate_package_name ( & registry, "registry name" , "" ) ?;
@@ -344,6 +354,17 @@ pub fn registry_configuration(
344
354
Ok ( RegistryConfig { index, token } )
345
355
}
346
356
357
+ /// Returns the `Registry` and `Source` based on command-line and config settings.
358
+ ///
359
+ /// * `token`: The token from the command-line. If not set, uses the token
360
+ /// from the config.
361
+ /// * `index`: The index URL from the command-line. This is ignored if
362
+ /// `registry` is set.
363
+ /// * `registry`: The registry name from the command-line. If neither
364
+ /// `registry`, or `index` are set, then uses `crates-io`, honoring
365
+ /// `[source]` replacement if defined.
366
+ /// * `force_update`: If `true`, forces the index to be updated.
367
+ /// * `validate_token`: If `true`, the token must be set.
347
368
fn registry (
348
369
config : & Config ,
349
370
token : Option < String > ,
@@ -739,6 +760,10 @@ pub fn yank(
739
760
Ok ( ( ) )
740
761
}
741
762
763
+ /// Gets the SourceId for an index or registry setting.
764
+ ///
765
+ /// The `index` and `reg` values are from the command-line or config settings.
766
+ /// If both are None, returns the source for crates.io.
742
767
fn get_source_id (
743
768
config : & Config ,
744
769
index : Option < String > ,
0 commit comments