oxyromon 0.24.0

Rusty ROM OrgaNizer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
use super::check_roms;
use super::config::{add_to_list, remove_from_list, set_bool, set_directory, set_string};
use super::convert_roms;
use super::database::*;
use super::download_dats::download_redump_system;
use super::generate_playlists;
use super::progress::*;
use super::purge_irds;
use super::purge_roms;
use super::purge_systems::purge_system;
use super::server::{SseMessage, sse_send};
use super::sort_roms;
use super::validator::*;
use async_graphql::{Context, Object, Result};
use futures::future::BoxFuture;
use serde_json::json;
use sqlx::SqliteConnection;
use sqlx::SqlitePool;
use tokio::sync::broadcast;

/// Spawn a background task that runs a CLI subcommand's `main()` and reports the
/// outcome over SSE as `{prefix}_started` / `{prefix}_complete` / `{prefix}_error`.
///
/// The connection is acquired *inside* the task and a failure to acquire is
/// reported as an SSE error rather than a panic, so the UI never hangs waiting
/// for a completion event that will never arrive. `{prefix}_started` goes out
/// first: with every connection taken, the action waits for one, and the UI
/// should show it has begun rather than nothing at all.
fn spawn_cli_action(
    pool: SqlitePool,
    sse_tx: broadcast::Sender<SseMessage>,
    prefix: &'static str,
    start_message: String,
    complete_message: String,
    fail_prefix: &'static str,
    run: impl for<'a> FnOnce(&'a mut SqliteConnection) -> BoxFuture<'a, anyhow::Result<()>>
    + Send
    + 'static,
) {
    tokio::spawn(async move {
        sse_send(
            &sse_tx,
            &format!("{prefix}_started"),
            json!({ "message": start_message }),
        );
        let mut connection = match pool.acquire().await {
            Ok(connection) => connection,
            Err(e) => {
                let message = format!("{fail_prefix}: {e}");
                sse_send(
                    &sse_tx,
                    &format!("{prefix}_error"),
                    json!({ "success": false, "message": message }),
                );
                log::error!("{message}");
                return;
            }
        };
        match run(&mut connection).await {
            Ok(()) => {
                log::info!("{complete_message}");
                sse_send(
                    &sse_tx,
                    &format!("{prefix}_complete"),
                    json!({ "success": true, "message": complete_message }),
                );
            }
            Err(e) => {
                let message = format!("{fail_prefix}: {e:#}");
                sse_send(
                    &sse_tx,
                    &format!("{prefix}_error"),
                    json!({ "success": false, "message": message }),
                );
                log::error!("{message}");
            }
        }
    });
}

/// The typed error returned by every mutation that resolves a caller-supplied
/// `system_id` before doing work.
fn system_not_found(system_id: i64) -> async_graphql::Error {
    async_graphql::Error::new(format!("System {system_id} not found"))
}

/// Acquire a pooled connection for a request-path mutation, turning a pool
/// failure into a typed GraphQL error instead of a panic. The spawned actions
/// hold their connections for the whole run, so under concurrency a request-path
/// acquire can genuinely fail; that must surface as an error, not a 500.
async fn acquire_connection(pool: &SqlitePool) -> Result<sqlx::pool::PoolConnection<sqlx::Sqlite>> {
    pool.acquire().await.map_err(|e| {
        async_graphql::Error::new(format!("Failed to acquire database connection: {e}"))
    })
}

pub struct Mutation;

#[Object]
impl Mutation {
    async fn add_to_list(
        &self,
        ctx: &Context<'_>,
        key: String,
        value: String,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::add_to_list({}, {})", key, value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let progress_bar = get_progress_bar(0, get_none_progress_style());
        let mut connection = acquire_connection(pool).await?;
        add_to_list(&mut connection, &progress_bar, &key, &value, system_id).await;
        Ok(true)
    }

    async fn remove_from_list(
        &self,
        ctx: &Context<'_>,
        key: String,
        value: String,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::remove_to_list({}, {})", key, value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let progress_bar = get_progress_bar(0, get_none_progress_style());
        let mut connection = acquire_connection(pool).await?;
        remove_from_list(&mut connection, &progress_bar, &key, &value, system_id).await;
        Ok(true)
    }

    async fn set_bool(
        &self,
        ctx: &Context<'_>,
        key: String,
        value: bool,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::set_bool({}, {})", key, value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let mut connection = acquire_connection(pool).await?;
        set_bool(&mut connection, &key, value, system_id).await;
        Ok(true)
    }

    async fn set_prefer_regions(
        &self,
        ctx: &Context<'_>,
        #[graphql(validator(custom = "PreferRegionValidator::new()"))] value: String,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::set_prefer_regions({})", value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let mut connection = acquire_connection(pool).await?;
        set_string(&mut connection, "PREFER_REGIONS", &value, system_id).await;
        Ok(true)
    }

    async fn set_prefer_versions(
        &self,
        ctx: &Context<'_>,
        #[graphql(validator(custom = "PreferVersionValidator::new()"))] value: String,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::set_prefer_versions({})", value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let mut connection = acquire_connection(pool).await?;
        set_string(&mut connection, "PREFER_VERSIONS", &value, system_id).await;
        Ok(true)
    }

    async fn set_prefer_format(
        &self,
        ctx: &Context<'_>,
        #[graphql(validator(custom = "PreferFormatValidator::new()"))] value: String,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::set_prefer_format({})", value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let mut connection = acquire_connection(pool).await?;
        if let Some(system_id) = system_id
            && let Some(system) = find_system_by_id_opt(&mut connection, system_id).await
            && !convert_roms::format_supported_for_system(&system, &value)
        {
            return Err(async_graphql::Error::new(format!(
                "Only {:?} are supported for arcade systems",
                convert_roms::ARCADE_FORMATS
            )));
        }
        set_string(&mut connection, "PREFER_FORMAT", &value, system_id).await;
        Ok(true)
    }

    async fn unset_prefer_format(&self, ctx: &Context<'_>, system_id: Option<i64>) -> Result<bool> {
        log::debug!("mutation::unset_prefer_format()");
        let pool = ctx.data_unchecked::<SqlitePool>();
        let mut connection = acquire_connection(pool).await?;
        if let Some(setting) =
            find_setting_by_key(&mut connection, "PREFER_FORMAT", system_id).await
        {
            update_setting(&mut connection, setting.id, None).await;
        }
        Ok(true)
    }

    async fn set_subfolder_scheme(
        &self,
        ctx: &Context<'_>,
        key: String,
        #[graphql(validator(custom = "SubfolderSchemeValidator::new()"))] value: String,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::set_subfolder_scheme({}, {})", key, value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let mut connection = acquire_connection(pool).await?;
        set_string(&mut connection, &key, &value, system_id).await;
        Ok(true)
    }

    async fn set_directory(
        &self,
        ctx: &Context<'_>,
        key: String,
        #[graphql(validator(custom = "DirectoryValidator::new()"))] value: String,
        system_id: Option<i64>,
    ) -> Result<bool> {
        log::debug!("mutation::set_directory({}, {})", key, value);
        let pool = ctx.data_unchecked::<SqlitePool>();
        let mut connection = acquire_connection(pool).await?;
        set_directory(&mut connection, &key, &value, system_id).await;
        Ok(true)
    }

    /// Fetch the named Redump systems' DAT files and import them.
    ///
    /// Returns as soon as the work is handed to a background task; progress and
    /// the outcome arrive over SSE, the same way importing an uploaded DAT does.
    async fn download_dats(&self, ctx: &Context<'_>, systems: Vec<String>) -> Result<bool> {
        log::debug!("mutation::download_dats({:?})", systems);
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();

        tokio::spawn(async move {
            let mut connection = match pool.acquire().await {
                Ok(connection) => connection,
                Err(e) => {
                    sse_send(
                        &sse_tx,
                        "download_dats_error",
                        json!({
                            "success": false,
                            "message": format!("Failed to download DAT files: {e}"),
                        }),
                    );
                    log::error!("Failed to acquire connection to download DAT files: {e}");
                    return;
                }
            };
            let progress_bar = ProgressBar::hidden();
            let total = systems.len();

            sse_send(
                &sse_tx,
                "download_dats_started",
                json!({
                    "total": total,
                    "message": format!("Downloading {} DAT file(s)", total),
                }),
            );

            // Deliberately quiet between the two: a per-system event would mean
            // a toast each, and this list can run to the whole catalogue.
            let mut failed: Vec<String> = Vec::new();
            for system_name in systems.iter() {
                if let Err(e) =
                    download_redump_system(&mut connection, &progress_bar, system_name, false).await
                {
                    log::error!("Failed to download {}: {:#}", system_name, e);
                    failed.push(system_name.clone());
                }
            }

            if failed.is_empty() {
                sse_send(
                    &sse_tx,
                    "download_dats_complete",
                    json!({
                        "total": total,
                        "success": true,
                        "message": format!("Downloaded {} DAT file(s)", total),
                    }),
                );
            } else {
                sse_send(
                    &sse_tx,
                    "download_dats_error",
                    json!({
                        "success": false,
                        "failed": failed,
                        "message": format!("Failed to download: {}", failed.join(", ")),
                    }),
                );
            }
        });

        Ok(true)
    }

    async fn purge_system(&self, ctx: &Context<'_>, system_id: i64) -> Result<bool> {
        log::debug!("mutation::purge_system({})", system_id);
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();
        let mut connection = acquire_connection(&pool).await?;

        let system = match find_system_by_id_opt(&mut connection, system_id).await {
            Some(system) => system,
            None => return Err(system_not_found(system_id)),
        };
        let system_name = system.name.clone();

        // Spawn background task for deletion
        tokio::spawn(async move {
            let mut connection = match pool.acquire().await {
                Ok(connection) => connection,
                Err(e) => {
                    sse_send(
                        &sse_tx,
                        "purge_error",
                        json!({
                            "system_id": system_id,
                            "system_name": system_name,
                            "success": false,
                            "error": format!("{e}"),
                            "message": format!("Failed to delete system '{}': {e}", system_name)
                        }),
                    );
                    log::error!("Failed to acquire connection to purge system {system_id}: {e}");
                    return;
                }
            };
            let progress_bar = ProgressBar::hidden();

            // Send start notification
            sse_send(
                &sse_tx,
                "purge_started",
                json!({
                    "system_id": system_id,
                    "system_name": system_name,
                    "message": format!("Starting deletion of system '{}'", system_name)
                }),
            );

            // Perform the actual deletion
            match purge_system(&mut connection, &progress_bar, &system).await {
                Ok(_) => {
                    sse_send(
                        &sse_tx,
                        "purge_complete",
                        json!({
                            "system_id": system_id,
                            "system_name": system_name,
                            "success": true,
                            "message": format!("System '{}' has been successfully deleted", system_name)
                        }),
                    );
                    log::info!("Successfully purged system: {}", system_name);
                }
                Err(e) => {
                    sse_send(
                        &sse_tx,
                        "purge_error",
                        json!({
                            "system_id": system_id,
                            "system_name": system_name,
                            "success": false,
                            "error": format!("{:#}", e),
                            "message": format!("Failed to delete system '{}': {:#}", system_name, e)
                        }),
                    );
                    log::error!("Failed to purge system {}: {:#}", system_name, e);
                }
            }
        });

        Ok(true)
    }

    /// Sort the ROMs of the given system, or of every system when none is
    /// given, according to the region and version preferences.
    ///
    /// Returns as soon as the work is handed to a background task; the outcome
    /// arrives over SSE, the same way purging a system does.
    async fn sort_roms(&self, ctx: &Context<'_>, system_id: Option<i64>) -> Result<bool> {
        log::debug!("mutation::sort_roms({:?})", system_id);
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();
        let mut connection = acquire_connection(&pool).await?;

        let system_name = match system_id {
            Some(system_id) => match find_system_by_id_opt(&mut connection, system_id).await {
                Some(system) => Some(system.name),
                None => return Err(system_not_found(system_id)),
            },
            None => None,
        };

        let message = match &system_name {
            Some(name) => format!("Sorting the ROMs of '{}'", name),
            None => "Sorting the ROMs of all systems".to_string(),
        };
        let complete_message = match &system_name {
            Some(name) => format!("Sorted the ROMs of '{}'", name),
            None => "Sorted the ROMs of all systems".to_string(),
        };

        spawn_cli_action(
            pool,
            sse_tx,
            "sort_roms",
            message,
            complete_message,
            "Failed to sort ROMs",
            move |connection| {
                Box::pin(async move {
                    let progress_bar = ProgressBar::hidden();
                    let mut arguments: Vec<String> = vec!["sort-roms".to_string()];
                    match system_name {
                        Some(name) => {
                            arguments.push("-s".to_string());
                            arguments.push(name);
                        }
                        None => arguments.push("-a".to_string()),
                    }
                    // The action was asked for from the UI, so answer the
                    // per-system confirmation instead of waiting on a TTY.
                    arguments.push("-y".to_string());
                    let matches = sort_roms::subcommand().try_get_matches_from(arguments)?;
                    sort_roms::main(connection, &matches, &progress_bar).await
                })
            },
        );

        Ok(true)
    }

    /// Check the integrity of the ROMs of the given system, or of every system
    /// when none is given, by re-hashing them; corrupt files are moved to the
    /// Trash directory.
    async fn check_roms(&self, ctx: &Context<'_>, system_id: Option<i64>) -> Result<bool> {
        log::debug!("mutation::check_roms({:?})", system_id);
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();
        let mut connection = acquire_connection(&pool).await?;

        let system_name = match system_id {
            Some(system_id) => match find_system_by_id_opt(&mut connection, system_id).await {
                Some(system) => Some(system.name),
                None => return Err(system_not_found(system_id)),
            },
            None => None,
        };

        let message = match &system_name {
            Some(name) => format!("Checking the ROMs of '{}'", name),
            None => "Checking the ROMs of all systems".to_string(),
        };
        let complete_message = match &system_name {
            Some(name) => format!("Checked the ROMs of '{}'", name),
            None => "Checked the ROMs of all systems".to_string(),
        };

        spawn_cli_action(
            pool,
            sse_tx,
            "check_roms",
            message,
            complete_message,
            "Failed to check ROMs",
            move |connection| {
                Box::pin(async move {
                    let progress_bar = ProgressBar::hidden();
                    let mut arguments: Vec<String> = vec!["check-roms".to_string()];
                    match system_name {
                        Some(name) => {
                            arguments.push("--system".to_string());
                            arguments.push(name);
                        }
                        None => arguments.push("-a".to_string()),
                    }
                    let matches = check_roms::subcommand().try_get_matches_from(arguments)?;
                    check_roms::main(connection, &matches, &progress_bar).await
                })
            },
        );

        Ok(true)
    }

    /// Generate M3U playlists for every multi-disc game, across all systems.
    async fn generate_playlists(&self, ctx: &Context<'_>) -> Result<bool> {
        log::debug!("mutation::generate_playlists()");
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();

        spawn_cli_action(
            pool,
            sse_tx,
            "generate_playlists",
            "Generating playlists for all systems".to_string(),
            "Generated playlists for all systems".to_string(),
            "Failed to generate playlists",
            |connection| {
                Box::pin(async move {
                    let progress_bar = ProgressBar::hidden();
                    let arguments = vec!["generate-playlists".to_string(), "-a".to_string()];
                    let matches =
                        generate_playlists::subcommand().try_get_matches_from(arguments)?;
                    generate_playlists::main(connection, &matches, &progress_bar).await
                })
            },
        );

        Ok(true)
    }

    /// Purge the selected categories of ROM files: missing, orphan, trashed,
    /// and foreign.
    async fn purge_roms(
        &self,
        ctx: &Context<'_>,
        missing: bool,
        orphan: bool,
        trash: bool,
        foreign: bool,
    ) -> Result<bool> {
        log::debug!(
            "mutation::purge_roms({}, {}, {}, {})",
            missing,
            orphan,
            trash,
            foreign
        );
        if !(missing || orphan || trash || foreign) {
            return Err(async_graphql::Error::new("No ROM files selected to purge"));
        }
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();

        spawn_cli_action(
            pool,
            sse_tx,
            "purge_roms",
            "Purging ROM files".to_string(),
            "Purged ROM files".to_string(),
            "Failed to purge ROM files",
            move |connection| {
                Box::pin(async move {
                    let progress_bar = ProgressBar::hidden();
                    let mut arguments: Vec<String> = vec!["purge-roms".to_string()];
                    if missing {
                        arguments.push("-m".to_string());
                    }
                    if orphan {
                        arguments.push("-o".to_string());
                    }
                    if trash {
                        arguments.push("-t".to_string());
                    }
                    if foreign {
                        arguments.push("-f".to_string());
                    }
                    arguments.push("-y".to_string());
                    let matches = purge_roms::subcommand().try_get_matches_from(arguments)?;
                    purge_roms::main(connection, &matches, &progress_bar).await
                })
            },
        );

        Ok(true)
    }

    /// Convert the ROM files of the given system to the given format.
    async fn convert_roms(
        &self,
        ctx: &Context<'_>,
        system_id: i64,
        format: String,
    ) -> Result<bool> {
        log::debug!("mutation::convert_roms({}, {:?})", system_id, format);
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();
        let mut connection = acquire_connection(&pool).await?;

        let system_name = match find_system_by_id_opt(&mut connection, system_id).await {
            Some(system) => system.name,
            None => return Err(system_not_found(system_id)),
        };
        if !convert_roms::ALL_FORMATS.contains(&format.as_str()) {
            return Err(async_graphql::Error::new(format!(
                "Unsupported format '{}'; expected one of {}",
                format,
                convert_roms::ALL_FORMATS.join(", ")
            )));
        }

        let message = format!("Converting the ROMs of '{}' to {}", system_name, format);
        let complete_message = format!("Converted the ROMs of '{}' to {}", system_name, format);

        spawn_cli_action(
            pool,
            sse_tx,
            "convert_roms",
            message,
            complete_message,
            "Failed to convert ROMs",
            move |connection| {
                Box::pin(async move {
                    let progress_bar = ProgressBar::hidden();
                    let arguments: Vec<String> = vec![
                        "convert-roms".to_string(),
                        "-s".to_string(),
                        system_name,
                        "-f".to_string(),
                        format,
                    ];
                    let matches = convert_roms::subcommand().try_get_matches_from(arguments)?;
                    convert_roms::main(connection, &matches, &progress_bar).await
                })
            },
        );

        Ok(true)
    }

    /// Purge every IRD (JB folder) game of one system.
    async fn purge_irds(&self, ctx: &Context<'_>, system_id: i64) -> Result<bool> {
        log::debug!("mutation::purge_irds({})", system_id);
        let pool = ctx.data_unchecked::<SqlitePool>().clone();
        let sse_tx = ctx
            .data_unchecked::<broadcast::Sender<SseMessage>>()
            .clone();
        let mut connection = acquire_connection(&pool).await?;
        let system_name = match find_system_by_id_opt(&mut connection, system_id).await {
            Some(system) => system.name,
            None => return Err(system_not_found(system_id)),
        };

        let message = format!("Purging the IRDs of '{}'", system_name);
        let complete_message = format!("Purged the IRDs of '{}'", system_name);

        spawn_cli_action(
            pool,
            sse_tx,
            "purge_irds",
            message,
            complete_message,
            "Failed to purge IRDs",
            move |connection| {
                Box::pin(async move {
                    let progress_bar = ProgressBar::hidden();
                    let arguments = vec![
                        "purge-irds".to_string(),
                        "--system".to_string(),
                        system_name,
                    ];
                    let matches = purge_irds::subcommand().try_get_matches_from(arguments)?;
                    purge_irds::main(connection, &matches, &progress_bar).await
                })
            },
        );

        Ok(true)
    }
}