maincopy-cli 0.1.0

Operator command-line client for the Maincopy administration API
Documentation
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
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
//! Command-line input models.

mod agents;
pub(crate) use agents::AgentCommand;
mod profile;
mod source;
pub(crate) use source::SourceConfigurationArguments;
mod users;
pub(crate) use profile::{
    ProfileCommand, ProfileInvocation, TipRecipientCommand, TipRecipientInvocation,
};
pub(crate) use users::{
    CreateUserArguments, InitialCredentials, LoginCredentialArguments, UserCommand,
    UserCredentialCommand,
};

use std::path::PathBuf;

use clap::{Args, Parser, Subcommand, ValueEnum};
use maincopy_shared::publication::PreviewDigest;
use time::{OffsetDateTime, UtcOffset, format_description::well_known::Rfc3339};
use uuid::Uuid;

#[derive(Debug, Parser)]
#[command(
    name = "maincopy",
    version,
    about = "Operate a running Maincopy server."
)]
pub(crate) struct Arguments {
    /// Write one machine-readable JSON document.
    #[arg(long, global = true)]
    pub(crate) json: bool,

    /// Canonical HTTPS origin of the private administration API.
    #[arg(
        long,
        global = true,
        value_name = "HTTPS_ORIGIN",
        default_value = "https://admin.localhost"
    )]
    pub(crate) admin_origin: Box<str>,

    /// Additional PEM certificate authorities trusted on Linux and macOS.
    #[arg(long, global = true, value_name = "PEM_PATH")]
    pub(crate) admin_ca_file: Option<PathBuf>,

    /// Protected credential context used for administration requests.
    #[arg(long, global = true, value_enum, default_value_t = AuthenticationContext::Human)]
    pub(crate) auth_context: AuthenticationContext,

    #[command(subcommand)]
    pub(crate) command: Command,
}

#[derive(Debug, Subcommand)]
pub(crate) enum Command {
    /// Register, inspect, update, and revoke agent grants.
    Agents {
        #[command(subcommand)]
        command: AgentCommand,
    },
    /// Inspect accounts and replace their status or roles.
    Users {
        #[command(subcommand)]
        command: UserCommand,
    },
    /// Inspect or replace your public display profile and Lightning Address.
    Profile {
        #[command(subcommand)]
        command: ProfileCommand,
    },
    /// Inspect, select, or clear the site's active tip recipient.
    TipRecipient {
        #[command(subcommand)]
        command: TipRecipientCommand,
    },
    /// Create and protect a password-authenticated human session.
    Login {
        /// Canonical account username. The password is read from the terminal.
        #[arg(long, value_name = "USERNAME")]
        username: Box<str>,
    },

    /// Create a human session using a challenge signed by your external Nostr signer.
    LoginNostr,

    /// Revoke the active human session and delete its protected local credentials.
    Logout,

    /// Manage the protected local Nostr private key used by the agent context.
    AgentKey {
        #[command(subcommand)]
        command: AgentKeyCommand,
    },

    /// Report the API versions supported by the running server.
    Capabilities,

    /// List post revisions loaded by the running server.
    Posts,

    /// Inspect durable releases and accepted operation receipts.
    Releases {
        #[command(subcommand)]
        command: ReleaseCommand,
    },

    /// Inspect and synchronize the configured article source.
    Source {
        #[command(subcommand)]
        command: SourceCommand,
    },

    /// Download one exact private post preview without overwriting a file.
    Preview {
        /// Stable post UUID to preview.
        #[arg(value_name = "POST_ID")]
        post_id: Uuid,

        /// Create this new HTML file; an existing path is never overwritten.
        #[arg(long, value_name = "PATH")]
        output: PathBuf,

        /// Require this exact typed post revision digest.
        #[arg(long, value_name = "DIGEST")]
        revision: Option<String>,

        /// Require this exact typed managed content-tree digest.
        #[arg(long, value_name = "DIGEST")]
        content_digest: Option<String>,
    },

    /// Publish the current eligible revision of one post immediately.
    PublishNow {
        /// Stable post UUID to publish.
        #[arg(value_name = "POST_ID")]
        post_id: Uuid,

        /// Exact private preview digest reviewed for this approval.
        #[arg(long, value_name = "DIGEST")]
        preview_digest: PreviewDigest,

        /// Require this exact typed post revision digest.
        #[arg(long, value_name = "DIGEST")]
        revision: Option<String>,

        /// Retry identity for this publication command; generated when omitted.
        #[arg(long, value_name = "UUID")]
        idempotency_key: Option<Uuid>,
    },

    /// Approve an exact post revision for publication at a UTC time.
    Schedule {
        /// Stable post UUID to schedule.
        #[arg(value_name = "POST_ID")]
        post_id: Uuid,

        /// Exact private preview digest reviewed for this approval.
        #[arg(long, value_name = "DIGEST")]
        preview_digest: PreviewDigest,

        /// UTC RFC3339 publication time, for example 2026-09-01T12:30:00Z.
        #[arg(long, value_name = "UTC_RFC3339", value_parser = parse_utc_rfc3339)]
        at: OffsetDateTime,

        /// Pin this exact typed post revision digest.
        #[arg(long, value_name = "DIGEST")]
        revision: Option<String>,

        /// Retry identity for this scheduling command; generated when omitted.
        #[arg(long, value_name = "UUID")]
        idempotency_key: Option<Uuid>,
    },
}

#[derive(Debug, Subcommand)]
pub(crate) enum ReleaseCommand {
    /// Fetch at most 100 releases, ordered by UUID.
    List {
        /// Continue with the next cursor from a previous page.
        #[arg(long)]
        cursor: Option<Uuid>,
    },
    /// Inspect the current durable state of a release.
    Inspect { publication_id: Uuid },
    /// Recover an immutable accepted operation result.
    Operation { operation_id: Uuid },
    /// Change a scheduled release's time without changing its approved revision.
    Reschedule {
        #[command(flatten)]
        target: ReleaseTarget,
        #[arg(long, value_name = "UTC_RFC3339", value_parser = parse_utc_rfc3339)]
        at: OffsetDateTime,
    },
    /// Cancel a scheduled or blocked release.
    Cancel(ReleaseTarget),
    /// Retry the exact approval of a blocked release.
    Retry(ReleaseTarget),
}

#[derive(Debug, Args)]
pub(crate) struct ReleaseTarget {
    pub(crate) publication_id: Uuid,
    /// Exact current resource version from releases inspect.
    #[arg(long, value_parser = clap::value_parser!(u64).range(1..i64::MAX as u64))]
    pub(crate) expected_version: u64,
    /// Operation UUID; generated when omitted. Reuse only with the identical command.
    #[arg(long, value_name = "UUID")]
    pub(crate) idempotency_key: Option<Uuid>,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum AuthenticationContext {
    Human,
    Agent,
}

#[derive(Debug, Subcommand)]
pub(crate) enum AgentKeyCommand {
    /// Show the selected local agent public key and its SHA-256 fingerprint.
    Inspect,
    /// Read a lowercase-hex Nostr private key from the terminal and protect it locally.
    Set,
    /// Delete the protected local agent key.
    Remove,
}

#[derive(Debug, Subcommand)]
pub(crate) enum SourceCommand {
    /// Show the selected deploy public key and its fingerprint.
    DeployKey,
    /// Validate proposed settings and install them after successful compilation.
    Configure(SourceConfigurationArguments),
    /// Report the configured source and its installed state.
    Status,

    /// Request one durable managed-source synchronization.
    Sync(SourceSyncArguments),
}

#[derive(Debug, Args)]
#[group(skip)]
pub(crate) struct SourceSyncArguments {
    /// Wait for the durable synchronization to reach a terminal state.
    #[arg(
        long,
        required_unless_present = "asynchronous",
        conflicts_with = "asynchronous"
    )]
    wait: bool,

    /// Return after the server accepts the durable synchronization.
    #[arg(long = "async", required_unless_present = "wait")]
    asynchronous: bool,

    /// Retry identity for this source synchronization; generated when omitted.
    #[arg(long, value_name = "UUID")]
    idempotency_key: Option<Uuid>,
}

impl SourceSyncArguments {
    pub(crate) fn into_invocation(self) -> SourceSyncInvocation {
        let disposition = match (self.wait, self.asynchronous) {
            (true, false) => SourceSyncDisposition::Wait,
            (false, true) => SourceSyncDisposition::Async,
            _ => unreachable!("clap enforces exactly one source-sync disposition"),
        };
        SourceSyncInvocation {
            disposition,
            idempotency_key: self.idempotency_key,
        }
    }
}

pub(crate) struct SourceSyncInvocation {
    pub(crate) disposition: SourceSyncDisposition,
    pub(crate) idempotency_key: Option<Uuid>,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum SourceSyncDisposition {
    Wait,
    Async,
}

fn parse_utc_rfc3339(value: &str) -> Result<OffsetDateTime, String> {
    let timestamp = OffsetDateTime::parse(value, &Rfc3339)
        .map_err(|_| "must be a valid RFC3339 timestamp".to_owned())?;
    if timestamp.offset() != UtcOffset::UTC {
        return Err("must use the UTC offset (Z or +00:00)".to_owned());
    }
    Ok(timestamp)
}

#[cfg(test)]
mod tests {
    use super::*;

    const PREVIEW_DIGEST: &str =
        "preview-b3-v1-4444444444444444444444444444444444444444444444444444444444444444";

    #[test]
    fn release_controls_require_a_version_and_accept_a_repeatable_operation() {
        let id = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa";
        for action in ["cancel", "retry", "reschedule"] {
            let mut args = vec![
                "maincopy",
                "releases",
                action,
                id,
                "--expected-version",
                "7",
                "--idempotency-key",
                id,
            ];
            if action == "reschedule" {
                args.extend(["--at", "2026-09-06T12:00:00Z"]);
            }
            let command = Arguments::try_parse_from(&args).unwrap().command;
            let Command::Releases { command } = command else {
                panic!("release command expected");
            };
            let target = match command {
                ReleaseCommand::Cancel(target)
                | ReleaseCommand::Retry(target)
                | ReleaseCommand::Reschedule { target, .. } => target,
                _ => panic!("release mutation expected"),
            };
            assert_eq!(target.expected_version, 7);
            assert_eq!(target.idempotency_key, Some(target.publication_id));
            assert!(Arguments::try_parse_from(["maincopy", "releases", action, id]).is_err());
        }
        for version in ["0", "-1", "9223372036854775807"] {
            assert!(
                Arguments::try_parse_from([
                    "maincopy",
                    "releases",
                    "cancel",
                    id,
                    "--expected-version",
                    version
                ])
                .is_err()
            );
        }
        assert!(
            Arguments::try_parse_from([
                "maincopy",
                "releases",
                "reschedule",
                id,
                "--expected-version",
                "1",
                "--at",
                "2026-09-06T12:00:00+01:00"
            ])
            .is_err()
        );
    }

    #[test]
    fn release_inspection_commands_parse_explicit_identities() {
        let id = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa";
        assert!(matches!(
            Arguments::try_parse_from(["maincopy", "releases", "list"])
                .unwrap()
                .command,
            Command::Releases {
                command: ReleaseCommand::List { cursor: None }
            }
        ));
        assert!(matches!(
            Arguments::try_parse_from(["maincopy", "releases", "list", "--cursor", id])
                .unwrap()
                .command,
            Command::Releases {
                command: ReleaseCommand::List { cursor: Some(_) }
            }
        ));
        assert!(matches!(
            Arguments::try_parse_from(["maincopy", "releases", "inspect", id])
                .unwrap()
                .command,
            Command::Releases {
                command: ReleaseCommand::Inspect { .. }
            }
        ));
        assert!(matches!(
            Arguments::try_parse_from(["maincopy", "releases", "operation", id])
                .unwrap()
                .command,
            Command::Releases {
                command: ReleaseCommand::Operation { .. }
            }
        ));
        assert!(Arguments::try_parse_from(["maincopy", "releases", "inspect", "bad"]).is_err());
    }

    #[test]
    fn client_arguments_select_capabilities_without_a_transport_flag() {
        let arguments = Arguments::try_parse_from(["maincopy", "capabilities"]).unwrap();

        assert!(!arguments.json);
        assert!(arguments.admin_ca_file.is_none());
        assert!(matches!(arguments.command, Command::Capabilities));
    }

    #[test]
    fn removed_socket_option_is_rejected() {
        assert!(
            Arguments::try_parse_from(["maincopy", "--socket", "admin.sock", "capabilities",])
                .is_err()
        );
    }

    #[test]
    fn global_options_are_accepted_after_the_command() {
        let arguments = Arguments::try_parse_from([
            "maincopy",
            "capabilities",
            "--json",
            "--admin-origin",
            "https://admin.example.test",
            "--admin-ca-file",
            "development-ca.pem",
            "--auth-context",
            "agent",
        ])
        .unwrap();

        assert!(arguments.json);
        assert_eq!(
            arguments.admin_origin.as_ref(),
            "https://admin.example.test"
        );
        assert_eq!(
            arguments.admin_ca_file.as_deref(),
            Some(std::path::Path::new("development-ca.pem"))
        );
        assert_eq!(arguments.auth_context, AuthenticationContext::Agent);
    }

    #[test]
    fn login_and_agent_key_commands_never_accept_secrets_on_argv() {
        let login =
            Arguments::try_parse_from(["maincopy", "login", "--username", "publisher"]).unwrap();
        assert!(matches!(
            login.command,
            Command::Login { ref username } if username.as_ref() == "publisher"
        ));
        assert!(
            Arguments::try_parse_from([
                "maincopy",
                "login",
                "--username",
                "publisher",
                "--password",
                "secret"
            ])
            .is_err()
        );
        assert!(
            Arguments::try_parse_from(["maincopy", "agent-key", "set", "--private-key", "secret"])
                .is_err()
        );
        let inspect = Arguments::try_parse_from(["maincopy", "agent-key", "inspect"]).unwrap();
        assert!(matches!(
            inspect.command,
            Command::AgentKey {
                command: AgentKeyCommand::Inspect
            }
        ));
    }

    #[test]
    fn posts_selects_the_loaded_post_listing_command() {
        let arguments = Arguments::try_parse_from(["maincopy", "posts"]).unwrap();

        assert!(matches!(arguments.command, Command::Posts));
    }

    #[test]
    fn source_status_selects_the_read_only_source_command() {
        let arguments = Arguments::try_parse_from(["maincopy", "source", "status"]).unwrap();

        assert!(matches!(
            arguments.command,
            Command::Source {
                command: SourceCommand::Status
            }
        ));
    }

    #[test]
    fn source_sync_requires_exactly_one_wait_disposition() {
        let key = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa";
        let wait = Arguments::try_parse_from([
            "maincopy",
            "source",
            "sync",
            "--wait",
            "--idempotency-key",
            key,
        ])
        .unwrap();
        let Command::Source {
            command: SourceCommand::Sync(wait),
        } = wait.command
        else {
            panic!("source sync must select the durable source command");
        };
        let wait = wait.into_invocation();
        assert_eq!(wait.disposition, SourceSyncDisposition::Wait);
        assert_eq!(wait.idempotency_key, Some(Uuid::parse_str(key).unwrap()));

        let asynchronous =
            Arguments::try_parse_from(["maincopy", "source", "sync", "--async"]).unwrap();
        let Command::Source {
            command: SourceCommand::Sync(asynchronous),
        } = asynchronous.command
        else {
            panic!("source sync must select the durable source command");
        };
        let asynchronous = asynchronous.into_invocation();
        assert_eq!(asynchronous.disposition, SourceSyncDisposition::Async);
        assert!(asynchronous.idempotency_key.is_none());

        assert!(Arguments::try_parse_from(["maincopy", "source", "sync"]).is_err());
        assert!(
            Arguments::try_parse_from(["maincopy", "source", "sync", "--wait", "--async"]).is_err()
        );
    }

    #[test]
    fn preview_parses_required_output_and_optional_exact_selectors() {
        let arguments = Arguments::try_parse_from([
            "maincopy",
            "preview",
            "11111111-1111-4111-8111-111111111111",
            "--output",
            "ready.html",
            "--revision",
            "post-b3-v1-1111111111111111111111111111111111111111111111111111111111111111",
            "--content-digest",
            "content-b3-v1-3333333333333333333333333333333333333333333333333333333333333333",
        ])
        .unwrap();

        let Command::Preview {
            post_id,
            output,
            revision,
            content_digest,
        } = arguments.command
        else {
            panic!("preview must select the private preview command");
        };
        assert_eq!(
            post_id,
            Uuid::parse_str("11111111-1111-4111-8111-111111111111").unwrap()
        );
        assert_eq!(output, PathBuf::from("ready.html"));
        assert_eq!(
            revision.as_deref(),
            Some("post-b3-v1-1111111111111111111111111111111111111111111111111111111111111111")
        );
        assert_eq!(
            content_digest.as_deref(),
            Some("content-b3-v1-3333333333333333333333333333333333333333333333333333333333333333")
        );
    }

    #[test]
    fn preview_requires_an_explicit_output_path() {
        let error = Arguments::try_parse_from([
            "maincopy",
            "preview",
            "11111111-1111-4111-8111-111111111111",
        ])
        .unwrap_err();

        assert_eq!(
            error.kind(),
            clap::error::ErrorKind::MissingRequiredArgument
        );
    }

    #[test]
    fn publication_commands_require_a_typed_reviewed_preview() {
        for command in ["publish-now", "schedule"] {
            let mut arguments = vec!["maincopy", command, "11111111-1111-4111-8111-111111111111"];
            if command == "schedule" {
                arguments.extend(["--at", "2026-09-01T12:30:00Z"]);
            }
            let error = Arguments::try_parse_from(arguments).unwrap_err();
            assert_eq!(
                error.kind(),
                clap::error::ErrorKind::MissingRequiredArgument
            );
        }
    }

    #[test]
    fn publish_now_parses_optional_revision_and_retry_identity() {
        let arguments = Arguments::try_parse_from([
            "maincopy",
            "publish-now",
            "11111111-1111-4111-8111-111111111111",
            "--preview-digest",
            PREVIEW_DIGEST,
            "--revision",
            "post-b3-v1-1111111111111111111111111111111111111111111111111111111111111111",
            "--idempotency-key",
            "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",
        ])
        .unwrap();

        let Command::PublishNow {
            post_id,
            preview_digest,
            revision,
            idempotency_key,
        } = arguments.command
        else {
            panic!("publish-now must select the publication command");
        };
        assert_eq!(
            post_id,
            Uuid::parse_str("11111111-1111-4111-8111-111111111111").unwrap()
        );
        assert_eq!(
            preview_digest,
            PreviewDigest::parse(PREVIEW_DIGEST).unwrap()
        );
        assert_eq!(
            revision.as_deref(),
            Some("post-b3-v1-1111111111111111111111111111111111111111111111111111111111111111")
        );
        assert_eq!(
            idempotency_key,
            Some(Uuid::parse_str("bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb").unwrap())
        );
    }

    #[test]
    fn publish_now_generates_the_retry_identity_only_at_execution() {
        let arguments = Arguments::try_parse_from([
            "maincopy",
            "publish-now",
            "11111111-1111-4111-8111-111111111111",
            "--preview-digest",
            PREVIEW_DIGEST,
        ])
        .unwrap();

        assert!(matches!(
            arguments.command,
            Command::PublishNow {
                revision: None,
                idempotency_key: None,
                ..
            }
        ));
    }

    #[test]
    fn schedule_parses_an_exact_utc_time_revision_and_retry_identity() {
        let arguments = Arguments::try_parse_from([
            "maincopy",
            "schedule",
            "11111111-1111-4111-8111-111111111111",
            "--preview-digest",
            PREVIEW_DIGEST,
            "--at",
            "2026-09-01T12:30:00Z",
            "--revision",
            "post-b3-v1-1111111111111111111111111111111111111111111111111111111111111111",
            "--idempotency-key",
            "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",
        ])
        .unwrap();

        let Command::Schedule {
            post_id,
            preview_digest,
            at,
            revision,
            idempotency_key,
        } = arguments.command
        else {
            panic!("schedule must select the scheduled approval command");
        };
        assert_eq!(
            post_id,
            Uuid::parse_str("11111111-1111-4111-8111-111111111111").unwrap()
        );
        assert_eq!(at.offset(), UtcOffset::UTC);
        assert_eq!(
            preview_digest,
            PreviewDigest::parse(PREVIEW_DIGEST).unwrap()
        );
        assert_eq!(
            at,
            OffsetDateTime::parse("2026-09-01T12:30:00Z", &Rfc3339).unwrap()
        );
        assert_eq!(
            revision.as_deref(),
            Some("post-b3-v1-1111111111111111111111111111111111111111111111111111111111111111")
        );
        assert_eq!(
            idempotency_key,
            Some(Uuid::parse_str("bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb").unwrap())
        );
    }

    #[test]
    fn schedule_rejects_non_utc_and_malformed_times() {
        for at in ["2026-09-01T14:30:00+02:00", "tomorrow"] {
            let error = Arguments::try_parse_from([
                "maincopy",
                "schedule",
                "11111111-1111-4111-8111-111111111111",
                "--preview-digest",
                PREVIEW_DIGEST,
                "--at",
                at,
            ])
            .unwrap_err();

            assert_eq!(error.kind(), clap::error::ErrorKind::ValueValidation);
        }
    }
}