@@ -2,7 +2,7 @@ use crate::dialoguer;
22use anyhow:: Context ;
33use chrono:: { NaiveDateTime , Utc } ;
44use colored:: Colorize ;
5- use crates_io:: models:: NewDeletedCrate ;
5+ use crates_io:: models:: { NewDeletedCrate , User } ;
66use crates_io:: schema:: { crate_downloads, deleted_crates} ;
77use crates_io:: worker:: jobs;
88use crates_io:: { db, schema:: crates} ;
@@ -29,6 +29,10 @@ pub struct Opts {
2929 /// Don't ask for confirmation: yes, we are sure. Best for scripting.
3030 #[ arg( short, long) ]
3131 yes : bool ,
32+
33+ /// Your GitHub username.
34+ #[ arg( long) ]
35+ deleted_by : String ,
3236}
3337
3438pub async fn run ( opts : Opts ) -> anyhow:: Result < ( ) > {
@@ -47,6 +51,10 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
4751 . await
4852 . context ( "Failed to look up crate name from the database" ) ?;
4953
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+
5058 println ! ( "Deleting the following crates:" ) ;
5159 println ! ( ) ;
5260 for name in & crate_names {
@@ -71,6 +79,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
7179 let deleted_crate = NewDeletedCrate :: builder ( name)
7280 . created_at ( & created_at)
7381 . deleted_at ( & now)
82+ . deleted_by ( deleted_by. id )
7483 . available_at ( & now)
7584 . build ( ) ;
7685
0 commit comments