4
4
5
5
mod login;
6
6
mod logout;
7
+ mod owner;
7
8
mod publish;
8
9
mod search;
9
10
mod yank;
@@ -20,18 +21,19 @@ use curl::easy::{Easy, InfoType, SslOpt, SslVersion};
20
21
use log:: { log, Level } ;
21
22
22
23
use crate :: core:: source:: Source ;
23
- use crate :: core:: { SourceId , Workspace } ;
24
+ use crate :: core:: SourceId ;
24
25
use crate :: sources:: { RegistrySource , SourceConfigMap } ;
25
26
use crate :: util:: auth:: { self , Secret } ;
26
27
use crate :: util:: config:: { Config , SslVersionConfig , SslVersionConfigRange } ;
27
28
use crate :: util:: errors:: CargoResult ;
28
- use crate :: util:: important_paths:: find_root_manifest_for_wd;
29
29
use crate :: util:: network;
30
30
use crate :: util:: IntoUrl ;
31
- use crate :: { drop_print , drop_println , version} ;
31
+ use crate :: version;
32
32
33
33
pub use self :: login:: registry_login;
34
34
pub use self :: logout:: registry_logout;
35
+ pub use self :: owner:: modify_owners;
36
+ pub use self :: owner:: OwnersOptions ;
35
37
pub use self :: publish:: publish;
36
38
pub use self :: publish:: PublishOpts ;
37
39
pub use self :: search:: search;
@@ -354,85 +356,6 @@ impl HttpTimeout {
354
356
}
355
357
}
356
358
357
- pub struct OwnersOptions {
358
- pub krate : Option < String > ,
359
- pub token : Option < Secret < String > > ,
360
- pub index : Option < String > ,
361
- pub to_add : Option < Vec < String > > ,
362
- pub to_remove : Option < Vec < String > > ,
363
- pub list : bool ,
364
- pub registry : Option < String > ,
365
- }
366
-
367
- pub fn modify_owners ( config : & Config , opts : & OwnersOptions ) -> CargoResult < ( ) > {
368
- let name = match opts. krate {
369
- Some ( ref name) => name. clone ( ) ,
370
- None => {
371
- let manifest_path = find_root_manifest_for_wd ( config. cwd ( ) ) ?;
372
- let ws = Workspace :: new ( & manifest_path, config) ?;
373
- ws. current ( ) ?. package_id ( ) . name ( ) . to_string ( )
374
- }
375
- } ;
376
-
377
- let mutation = auth:: Mutation :: Owners { name : & name } ;
378
-
379
- let ( mut registry, _) = registry (
380
- config,
381
- opts. token . as_ref ( ) . map ( Secret :: as_deref) ,
382
- opts. index . as_deref ( ) ,
383
- opts. registry . as_deref ( ) ,
384
- true ,
385
- Some ( mutation) ,
386
- ) ?;
387
-
388
- if let Some ( ref v) = opts. to_add {
389
- let v = v. iter ( ) . map ( |s| & s[ ..] ) . collect :: < Vec < _ > > ( ) ;
390
- let msg = registry. add_owners ( & name, & v) . with_context ( || {
391
- format ! (
392
- "failed to invite owners to crate `{}` on registry at {}" ,
393
- name,
394
- registry. host( )
395
- )
396
- } ) ?;
397
-
398
- config. shell ( ) . status ( "Owner" , msg) ?;
399
- }
400
-
401
- if let Some ( ref v) = opts. to_remove {
402
- let v = v. iter ( ) . map ( |s| & s[ ..] ) . collect :: < Vec < _ > > ( ) ;
403
- config
404
- . shell ( )
405
- . status ( "Owner" , format ! ( "removing {:?} from crate {}" , v, name) ) ?;
406
- registry. remove_owners ( & name, & v) . with_context ( || {
407
- format ! (
408
- "failed to remove owners from crate `{}` on registry at {}" ,
409
- name,
410
- registry. host( )
411
- )
412
- } ) ?;
413
- }
414
-
415
- if opts. list {
416
- let owners = registry. list_owners ( & name) . with_context ( || {
417
- format ! (
418
- "failed to list owners of crate `{}` on registry at {}" ,
419
- name,
420
- registry. host( )
421
- )
422
- } ) ?;
423
- for owner in owners. iter ( ) {
424
- drop_print ! ( config, "{}" , owner. login) ;
425
- match ( owner. name . as_ref ( ) , owner. email . as_ref ( ) ) {
426
- ( Some ( name) , Some ( email) ) => drop_println ! ( config, " ({} <{}>)" , name, email) ,
427
- ( Some ( s) , None ) | ( None , Some ( s) ) => drop_println ! ( config, " ({})" , s) ,
428
- ( None , None ) => drop_println ! ( config) ,
429
- }
430
- }
431
- }
432
-
433
- Ok ( ( ) )
434
- }
435
-
436
359
/// Gets the SourceId for an index or registry setting.
437
360
///
438
361
/// The `index` and `reg` values are from the command-line or config settings.
0 commit comments