@@ -2,7 +2,7 @@ use crate::dialoguer;
2
2
use anyhow:: Context ;
3
3
use chrono:: { NaiveDateTime , Utc } ;
4
4
use colored:: Colorize ;
5
- use crates_io:: models:: NewDeletedCrate ;
5
+ use crates_io:: models:: { NewDeletedCrate , User } ;
6
6
use crates_io:: schema:: { crate_downloads, deleted_crates} ;
7
7
use crates_io:: worker:: jobs;
8
8
use crates_io:: { db, schema:: crates} ;
@@ -29,6 +29,10 @@ pub struct Opts {
29
29
/// Don't ask for confirmation: yes, we are sure. Best for scripting.
30
30
#[ arg( short, long) ]
31
31
yes : bool ,
32
+
33
+ /// Your GitHub username.
34
+ #[ arg( long) ]
35
+ deleted_by : String ,
32
36
}
33
37
34
38
pub async fn run ( opts : Opts ) -> anyhow:: Result < ( ) > {
@@ -47,6 +51,10 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
47
51
. await
48
52
. context ( "Failed to look up crate name from the database" ) ?;
49
53
54
+ let deleted_by = User :: async_find_by_login ( & mut conn, & opts. deleted_by )
55
+ . await
56
+ . context ( "Failed to look up `--deleted-by` user from the database" ) ?;
57
+
50
58
println ! ( "Deleting the following crates:" ) ;
51
59
println ! ( ) ;
52
60
for name in & crate_names {
@@ -73,6 +81,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
73
81
let deleted_crate = NewDeletedCrate :: builder ( name)
74
82
. created_at ( & created_at)
75
83
. deleted_at ( & now)
84
+ . deleted_by ( deleted_by. id )
76
85
. available_at ( & now)
77
86
. build ( ) ;
78
87
0 commit comments