putz u in dhe washing machin and spins ur bsky pofile pictuer !!! :D
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

read identifier & app pwd from env; make output arg optional

did:plc:73gqgbnvpx5syidcponjri… 67a4ab56 4065f4fe

verified
+38 -15
+38 -15
src/main.rs
··· 39 39 } 40 40 41 41 fn print_usage(executable: &str) { 42 - eprintln!( 43 - "usage: {} <input> <output> <app-password> <did/handle>", 44 - executable 45 - ); 42 + eprintln!("usage: {} <input> [output]", executable); 43 + eprintln!("environment variables:"); 44 + eprintln!(" APP_PASSWORD"); 45 + eprintln!(" IDENTIFIER - your handle or did"); 46 46 process::exit(1); 47 47 } 48 48 ··· 133 133 let mut args = env::args(); 134 134 let executable = args.next().unwrap_or_else(|| "washing-machine".to_string()); 135 135 136 - let (input, output, app_password, identifier) = 137 - match (args.next(), args.next(), args.next(), args.next()) { 138 - (Some(i), Some(o), Some(p), Some(id)) => (i, o, p, id), 139 - _ => { 140 - print_usage(&executable); 141 - return; 142 - } 143 - }; 136 + let input = match args.next() { 137 + Some(i) => i, 138 + None => { 139 + print_usage(&executable); 140 + return; 141 + } 142 + }; 143 + let output = args.next(); 144 + 145 + let app_password = env::var("APP_PASSWORD").unwrap_or_else(|_| { 146 + eprintln!("environment variable APP_PASSWORD not set"); 147 + print_usage(&executable); 148 + String::new() 149 + }); 150 + if app_password.trim().is_empty() { 151 + eprintln!("APP_PASSWORD is empty"); 152 + process::exit(1); 153 + } 154 + 155 + let identifier = env::var("IDENTIFIER").unwrap_or_else(|_| { 156 + eprintln!("environment variable IDENTIFIER not set"); 157 + print_usage(&executable); 158 + String::new() 159 + }); 160 + if identifier.trim().is_empty() { 161 + eprintln!("IDENTIFIER is empty"); 162 + process::exit(1); 163 + } 144 164 145 165 let (session, auth) = MemoryCredentialSession::authenticated( 146 166 identifier.to_cowstr(), ··· 183 203 184 204 let angle = compute_angle(); 185 205 let rotated = rotate_image(image, angle); 186 - rotated.save(&output).unwrap_or_else(|e| { 187 - eprintln!("failed to save '{}': {}", output.to_string(), e); 188 - }); 206 + 207 + if let Some(out) = &output { 208 + rotated.save(out).unwrap_or_else(|e| { 209 + eprintln!("failed to save '{}': {}", out.to_string(), e); 210 + }); 211 + } 189 212 190 213 update_avatar(rotated, &agent, &mime_type).await; 191 214