@@ -113,14 +113,17 @@ const MODE_LOSSY_YCBCR: u16 = 0b0000_0010_0000;
113113/// # Show B (Candidate) Image.
114114const OTHER_BSIDE : u16 = 0b0000_0100_0000 ;
115115
116+ /// # Exit After.
117+ const OTHER_EXIT_AUTO : u16 = 0b0000_1000_0000 ;
118+
116119/// # Night Mode.
117- const OTHER_NIGHT : u16 = 0b0000_1000_0000 ;
120+ const OTHER_NIGHT : u16 = 0b0001_0000_0000 ;
118121
119122/// # Save w/o Prompt.
120- const OTHER_SAVE_AUTO : u16 = 0b0001_0000_0000 ;
123+ const OTHER_SAVE_AUTO : u16 = 0b0010_0000_0000 ;
121124
122125/// # New Encoder.
123- const SWITCHED_ENCODER : u16 = 0b0010_0000_0000 ;
126+ const SWITCHED_ENCODER : u16 = 0b0100_0000_0000 ;
124127
125128/// # All Formats.
126129const FMT_FLAGS : u16 =
@@ -201,6 +204,7 @@ impl App {
201204 . with_keywords ( include ! ( concat!( env!( "OUT_DIR" ) , "/argyle.rs" ) ) ) ;
202205 for arg in args {
203206 match arg {
207+ Argument :: Key ( "-e" | "--exit-auto" ) => { flags |= OTHER_EXIT_AUTO ; } ,
204208 Argument :: Key ( "-h" | "--help" ) => return Err ( RefractError :: PrintHelp ) ,
205209 Argument :: Key ( "--no-avif" ) => { flags &= ! FMT_AVIF ; } ,
206210 Argument :: Key ( "--no-jxl" ) => { flags &= ! FMT_JXL ; } ,
@@ -372,30 +376,29 @@ impl App {
372376 } ,
373377
374378 // Record an "error" message so we can let the user know what's up.
375- Message :: Error ( err) => { self . error . replace ( err) ; } ,
379+ Message :: Error ( err) => {
380+ self . error . replace ( err) ;
381+ cli_log_error ( err) ;
382+ } ,
376383
377384 // Process the user's yay/nay evaluation of a candidate image.
378- Message :: Feedback ( feedback) =>
379- if let Some ( current) = & mut self . current {
380- if current. candidate . is_some ( ) {
381- self . flags &= ! OTHER_BSIDE ;
382- // Back around again!
383- if current. feedback ( feedback) {
384- return Task :: done ( Message :: NextStep ) ;
385- }
385+ Message :: Feedback ( feedback) => if let Some ( current) = & mut self . current {
386+ if current. candidate . is_some ( ) {
387+ self . flags &= ! OTHER_BSIDE ;
388+ // Back around again!
389+ if current. feedback ( feedback) {
390+ return Task :: done ( Message :: NextStep ) ;
386391 }
387- } ,
392+ }
393+ } ,
388394
389395 // Switch to the next encoder.
390396 Message :: NextEncoder =>
391397 if self . current . as_mut ( ) . is_some_and ( CurrentImage :: next_encoder) {
392398 return self . update_switch_encoder__ ( ) ;
393399 }
394400 // This image is done; move onto the next!
395- else {
396- self . current = None ;
397- if ! self . paths . is_empty ( ) { return Task :: done ( Message :: NextImage ) ; }
398- } ,
401+ else { return Task :: done ( Message :: NextImage ) ; } ,
399402
400403 // If there are images in the queue, pull the first and start up
401404 // the conversion process for it.
@@ -421,6 +424,10 @@ impl App {
421424 }
422425 }
423426 }
427+
428+ // If we're here, there are no more images. If --exit-auto,
429+ // that means quittin' time!
430+ if self . has_flag ( OTHER_EXIT_AUTO ) { return iced:: exit ( ) ; }
424431 } ,
425432
426433 // Spawn a thread to get the next candidate image crunching or, if
@@ -442,7 +449,7 @@ impl App {
442449 return Task :: done ( Message :: NextEncoder ) ;
443450 }
444451 // This image is done; move onto the next!
445- else if ! self . paths . is_empty ( ) { return Task :: done ( Message :: NextImage ) ; }
452+ return Task :: done ( Message :: NextImage ) ;
446453 } ,
447454
448455 // Reabsorb the encoder (stolen above) and either display the
@@ -466,7 +473,7 @@ impl App {
466473 return Task :: done ( Message :: NextEncoder ) ;
467474 }
468475 // This image is done; move onto the next!
469- else if ! self . paths . is_empty ( ) { return Task :: done ( Message :: NextImage ) ; }
476+ return Task :: done ( Message :: NextImage ) ;
470477 } ,
471478
472479 // Save the image and continue.
@@ -486,27 +493,21 @@ impl App {
486493 return Task :: done ( Message :: NextEncoder ) ;
487494 }
488495 // This image is done; move onto the next!
489- else if ! self . paths . is_empty ( ) { return Task :: done ( Message :: NextImage ) ; } ,
496+ else { return Task :: done ( Message :: NextImage ) ; } ,
490497
491498 // Open File/Dir Dialogue.
492499 Message :: OpenFd ( dir) => return self . open_fd ( dir) ,
493500
494501 // Open a local image path using whatever (external) program the
495502 // desktop environment would normally use to open that file type.
496- Message :: OpenFile ( src) =>
497- // If this fails, note the problem so we can let the user
498- // know that we aren't just ignoring them.
499- if open:: that_detached ( src) . is_err ( ) {
500- return Task :: done ( Message :: Error ( MessageError :: NoOpen ) ) ;
501- } ,
503+ Message :: OpenFile ( src) => if open:: that_detached ( src) . is_err ( ) {
504+ return Task :: done ( Message :: Error ( MessageError :: NoOpen ) ) ;
505+ } ,
502506
503507 // Open a URL in e.g. the system's default web browser.
504- Message :: OpenUrl ( url) =>
505- // If this fails, note the problem so we can let the user
506- // know that we aren't just ignoring them.
507- if open:: that_detached ( url) . is_err ( ) {
508- return Task :: done ( Message :: Error ( MessageError :: NoOpen ) ) ;
509- } ,
508+ Message :: OpenUrl ( url) => if open:: that_detached ( url) . is_err ( ) {
509+ return Task :: done ( Message :: Error ( MessageError :: NoOpen ) ) ;
510+ } ,
510511
511512 // Toggle a flag.
512513 Message :: ToggleFlag ( flag) => { self . toggle_flag ( flag) ; } ,
@@ -922,20 +923,30 @@ impl App {
922923 /// This returns checkboxes for the program's one-off settings, i.e.
923924 /// night mode and automatic saving.
924925 fn view_settings_other ( & self ) -> Column < Message > {
926+ macro_rules! tip {
927+ ( $label: literal, $flag: ident, $help: literal) => (
928+ tooltip(
929+ checkbox( $label, self . has_flag( $flag) )
930+ . on_toggle( |_| Message :: ToggleFlag ( $flag) )
931+ . size( CHK_SIZE ) ,
932+ container( text( $help) . size( 12 ) )
933+ . padding( 20 )
934+ . max_width( 300_u16 )
935+ . style( |_| tooltip_style( ! self . has_flag( OTHER_NIGHT ) ) ) ,
936+ tooltip:: Position :: Bottom ,
937+ )
938+ ) ;
939+ }
940+
925941 column ! (
926942 text( "Other" ) . color( NiceColors :: PINK ) . font( FONT_BOLD ) ,
927- tooltip(
928- checkbox( "Auto-Save" , self . has_flag( OTHER_SAVE_AUTO ) )
929- . on_toggle( |_| Message :: ToggleFlag ( OTHER_SAVE_AUTO ) )
930- . size( CHK_SIZE ) ,
931- container(
932- text( "Automatically save successful conversions to their source paths — with new extensions appended — instead of popping file dialogues for confirmation." )
933- . size( 12 )
934- )
935- . padding( 20 )
936- . max_width( 300_u16 )
937- . style( |_| tooltip_style( ! self . has_flag( OTHER_NIGHT ) ) ) ,
938- tooltip:: Position :: Bottom ,
943+ tip!(
944+ "Auto-Save" , OTHER_SAVE_AUTO ,
945+ "Automatically save successful conversions to their source paths — with new extensions appended — instead of popping file dialogues for confirmation."
946+ ) ,
947+ tip!(
948+ "Auto-Exit" , OTHER_SAVE_AUTO ,
949+ "Close the program after the last image has been processed."
939950 ) ,
940951 checkbox( "Night Mode" , self . has_flag( OTHER_NIGHT ) )
941952 . on_toggle( |_| Message :: ToggleFlag ( OTHER_NIGHT ) )
@@ -2180,7 +2191,7 @@ fn cli_log(src: &Path, quality: Option<Quality>) {
21802191
21812192/// # Cli Log: Sad Conversion.
21822193///
2183- /// Print a quick timestamped error message to STDERR.
2194+ /// Print a quick timestamped summary of a failed conversion to STDERR.
21842195fn cli_log_sad ( src : & Path ) {
21852196 let Some ( dir) = src. parent ( ) else { return ; } ;
21862197 let Some ( name) = src. file_name ( ) else { return ; } ;
@@ -2194,6 +2205,18 @@ fn cli_log_sad(src: &Path) {
21942205 ) ;
21952206}
21962207
2208+ /// # Cli Log: Error.
2209+ ///
2210+ /// Print a quick timestamped error message to STDERR.
2211+ fn cli_log_error ( src : MessageError ) {
2212+ let now = FmtUtc2k :: now_local ( ) ;
2213+ eprintln ! (
2214+ "\x1b [2m[\x1b [0;34m{}\x1b [0;2m]\x1b [0;93m Warning:\x1b [0m {}" ,
2215+ now. time( ) ,
2216+ src. as_str( ) ,
2217+ ) ;
2218+ }
2219+
21972220/// # General Subscriptions.
21982221///
21992222/// This callback for `on_key_press` binds listeners for the night mode
0 commit comments