perforce-cli 0.2.3

A type-safe builder library for spawning Perforce (p4) commands, with compile-time option state isolation and multi-version support.
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
735
736
737
738
739
use std::{
    ffi::OsStr,
    path::{Path, PathBuf},
    process::{Child, Command, Stdio},
};

use super::{ExclusiveOption, SubCommand, Unselected};

use crate::global::GlobalOpts;
use crate::spawn::ParameterizedSpawn;

/// The depot type selected with `-t type`.
///
/// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
#[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
#[cfg_attr(
    not(feature = "lt2017_1"),
    doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
)]
#[cfg(not(feature = "lt2015_2"))]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DepotType {
    /// A `local` depot (the default).
    Local,

    /// A `remote` depot.
    Remote,

    /// A `spec` depot.
    Spec,

    /// A `stream` depot.
    Stream,

    /// An `unload` depot.
    Unload,

    /// An `archive` depot.
    Archive,

    /// A `tangent` depot.
    Tangent,

    /// A `graph` depot, used to store Git repos in the server.
    #[cfg(not(feature = "lt2017_1"))]
    Graph,
}

#[cfg(not(feature = "lt2015_2"))]
impl DepotType {
    pub(crate) fn as_str(&self) -> &'static str {
        match self {
            Self::Local => "local",
            Self::Remote => "remote",
            Self::Spec => "spec",
            Self::Stream => "stream",
            Self::Unload => "unload",
            Self::Archive => "archive",
            Self::Tangent => "tangent",
            #[cfg(not(feature = "lt2017_1"))]
            Self::Graph => "graph",
        }
    }
}

/// Delete mode of `p4 depot` (`-d [-f]`).
///
/// Entered with [`Depot::delete`].
#[derive(Debug, Clone, Copy, Default)]
pub struct Delete {
    force: bool,
}

impl ExclusiveOption for Delete {
    fn inject_args(&self, command: &mut Command) {
        command.arg("-d");
        if self.force {
            command.arg("-f");
        }
    }
}

/// Stdout mode of `p4 depot` (`-o [-t type]`): write a depot specification
/// to standard output.
///
/// Entered with [`Depot::stdout`], or from the regular form with
/// [`Depot::stdout`](Depot::stdout).
#[derive(Debug, Clone, Default)]
pub struct Stdout {
    #[cfg(not(feature = "lt2015_2"))]
    depot_type: Option<DepotType>,
}

impl ExclusiveOption for Stdout {
    fn inject_args(&self, command: &mut Command) {
        command.arg("-o");
        #[cfg(not(feature = "lt2015_2"))]
        if let Some(depot_type) = &self.depot_type {
            command.arg("-t").arg(depot_type.as_str());
        }
    }
}

/// Stdin mode of `p4 depot` (`-i`): read a depot specification from standard
/// input.
///
/// Entered with [`Depot::stdin`].
#[derive(Debug, Clone, Copy, Default)]
pub struct Stdin {}

impl ExclusiveOption for Stdin {
    fn inject_args(&self, command: &mut Command) {
        command.arg("-i");
    }
}

/// Regular mode of `p4 depot` (`[-t type] depotname`): create or edit a
/// depot specification.
///
/// Entered with [`Depot::depot_type`]; [`Depot::stdout`](Depot::stdout)
/// transitions to the [`Stdout`] mode, preserving the selected depot type.
#[cfg(not(feature = "lt2015_2"))]
#[derive(Debug, Clone, Copy, Default)]
pub struct Regular {
    depot_type: Option<DepotType>,
}

#[cfg(not(feature = "lt2015_2"))]
impl ExclusiveOption for Regular {
    fn inject_args(&self, command: &mut Command) {
        if let Some(depot_type) = &self.depot_type {
            command.arg("-t").arg(depot_type.as_str());
        }
    }
}

#[cfg_attr(
    feature = "lt2015_2",
    doc = "`p4 [g-opts] depot depotname`\n\n\
           `p4 [g-opts] depot -d [-f] depotname`\n\n\
           `p4 [g-opts] depot -o depotname`\n\n\
           `p4 [g-opts] depot -i`"
)]
#[cfg_attr(
    not(feature = "lt2015_2"),
    doc = "`p4 [g-opts] depot [-t type] depotname`\n\n\
           `p4 [g-opts] depot -d [-f] depotname`\n\n\
           `p4 [g-opts] depot -o [-t type] depotname`\n\n\
           `p4 [g-opts] depot -i`"
)]
///
#[cfg_attr(feature = "lt2022_1", doc = "Create or edit a depot specification.")]
#[cfg_attr(
    all(feature = "lt2022_2", not(feature = "lt2022_1")),
    doc = "Create, edit, or delete a depot specification.",
    doc = "",
    doc = "A branch, depot, label, and workspace cannot have the same name."
)]
#[cfg_attr(
    all(feature = "lt2024_1", not(feature = "lt2022_2")),
    doc = "Create, edit, or delete a depot specification."
)]
#[cfg_attr(
    not(feature = "lt2024_1"),
    doc = "Create, edit, or delete a depot specification.",
    doc = "",
    doc = "A branch, depot, label, and workspace cannot share the same name."
)]
///
/// The `M` type parameter tracks the command form at compile time. The
/// default [`Unselected`] state is the regular form with no options;
/// [`Self::delete`], [`Self::stdout`], and [`Self::stdin`] transition to the
/// [`Delete`], [`Stdout`], and [`Stdin`] modes
#[cfg_attr(feature = "lt2015_2", doc = ".")]
#[cfg_attr(
    not(feature = "lt2015_2"),
    doc = ", while [`Self::depot_type`] transitions to the [`Regular`] mode carrying `-t type`."
)]
#[derive(Debug, Clone, Default)]
pub struct Depot<M = Unselected> {
    bin: PathBuf,

    global_opts: GlobalOpts,

    mode: M,
}

impl Depot<Unselected> {
    /// Creates a new `p4 depot` command.
    ///
    /// `bin` is the path to the Perforce command-line executable.
    pub fn new(bin: impl Into<PathBuf>, global_opts: GlobalOpts) -> Self {
        Self {
            bin: bin.into(),
            global_opts,
            mode: Unselected,
        }
    }

    /// # Description
    ///
    /// -d depotname
    ///
    /// Delete the depot *depotname*.
    ///
    #[cfg_attr(
        feature = "lt2015_2",
        doc = "The depot must not contain any files; the Perforce superuser can remove files with `p4 obliterate`.",
        doc = "",
        doc = "If the depot is `remote`, `p4 obliterate` must still be run: no files are deleted, but any outstanding client or label records referring to that depot are eliminated."
    )]
    #[cfg_attr(
        all(feature = "lt2017_2", not(feature = "lt2015_2")),
        doc = "The depot must not contain any files; the Perforce superuser can remove files with `p4 obliterate`.",
        doc = "",
        doc = "If the depot is `remote`, `p4 obliterate` must still be run: no files are deleted, but any outstanding client or label records referring to that depot are eliminated.",
        doc = "",
        doc = "The name of a depot may not be the same as the name of a branch, client workspace, or label."
    )]
    #[cfg_attr(
        all(feature = "lt2022_1", not(feature = "lt2017_2")),
        doc = "The depot must not contain any files; the Helix Server superuser can remove files with `p4 obliterate`.",
        doc = "",
        doc = "If the depot is `remote`, `p4 obliterate` must still be run: no files are deleted, but any outstanding client or label records referring to that depot are eliminated.",
        doc = "",
        doc = "The name of a depot may not be the same as the name of a branch, client workspace, or label."
    )]
    #[cfg_attr(
        all(feature = "lt2022_2", not(feature = "lt2022_1")),
        doc = "A classic depot must not contain any files. The Helix Core Server user with the `super` access level can remove files with `p4 obliterate`.",
        doc = "",
        doc = "A stream depot must not contain any stream specs. A Helix Core user with the `admin` access level can remove a stream with the `--obliterate` option of `p4 stream`.",
        doc = "",
        doc = "If the depot is `remote`, `p4 obliterate` must still be run. No files are deleted, but any outstanding client or label records referring to that depot are eliminated."
    )]
    #[cfg_attr(
        all(feature = "lt2024_2", not(feature = "lt2022_2")),
        doc = "A classic depot must not contain any files. The Helix Core Server user with the `super` access level can permanently remove files with `p4 obliterate`.",
        doc = "",
        doc = "A stream depot must not contain any streams. A Helix Core Server user with the `admin` access level can can use the `--obliterate` option of `p4 stream` to permanently remove a stream.",
        doc = "",
        doc = "If the depot is `remote`, `p4 obliterate` must still be run: no files are deleted, but any outstanding client or label records referring to that depot are eliminated.",
        doc = "",
        doc = "The name of a depot cannot be the same as the name of a branch, client workspace, or label."
    )]
    #[cfg_attr(
        not(feature = "lt2024_2"),
        doc = "A classic depot must not contain any files. The P4 Server user with the `super` access level can permanently remove files with `p4 obliterate`.",
        doc = "",
        doc = "A stream depot must not contain any streams. A P4 Server user with the `admin` access level can can use the `--obliterate` option of `p4 stream` to permanently remove a stream.",
        doc = "",
        doc = "If the depot is `remote`, `p4 obliterate` must still be run: no files are deleted, but any outstanding client or label records referring to that depot are eliminated.",
        doc = "",
        doc = "The name of a depot cannot be the same as the name of a branch, client workspace, or label."
    )]
    ///
    /// Transitions this command to the [`Delete`] mode.
    pub fn delete(self) -> Depot<Delete> {
        Depot {
            bin: self.bin,
            global_opts: self.global_opts,
            mode: Delete { force: false },
        }
    }

    /// # Description
    ///
    /// -o depotname
    ///
    /// Write a depot specification to standard output.
    ///
    /// Transitions this command to the [`Stdout`] mode.
    pub fn stdout(self) -> Depot<Stdout> {
        Depot {
            bin: self.bin,
            global_opts: self.global_opts,
            mode: Stdout {
                #[cfg(not(feature = "lt2015_2"))]
                depot_type: None,
            },
        }
    }

    /// # Description
    ///
    /// -i
    ///
    #[cfg_attr(
        feature = "lt2019_1",
        doc = "Read a depot specification from standard input."
    )]
    #[cfg_attr(
        not(feature = "lt2019_1"),
        doc = "Read a depot specification from standard input, or from a file in the case of `p4 depot -o -t stream mystreamdepot2 > filename` where content of filename is the depot spec."
    )]
    ///
    /// Transitions this command to the [`Stdin`] mode.
    pub fn stdin(self) -> Depot<Stdin> {
        Depot {
            bin: self.bin,
            global_opts: self.global_opts,
            mode: Stdin {},
        }
    }

    /// # Description
    ///
    /// -t type
    ///
    /// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
    #[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
    #[cfg_attr(
        not(feature = "lt2017_1"),
        doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
    )]
    ///
    /// Transitions this command to the [`Regular`] mode with the depot type
    /// set.
    #[cfg(not(feature = "lt2015_2"))]
    pub fn depot_type(self, v: DepotType) -> Depot<Regular> {
        Depot {
            bin: self.bin,
            global_opts: self.global_opts,
            mode: Regular {
                depot_type: Some(v),
            },
        }
    }
}

impl<I: AsRef<OsStr>> ParameterizedSpawn<(I,)> for Depot<Unselected> {
    type Output = Child;
    type Error = std::io::Error;

    /// Spawns `p4 depot depotname` with the given depot name as a child
    /// process with piped standard output and error streams; use the
    /// returned [`Child`] handle to wait for it or interact with it.
    fn spawn_with(&mut self, (depotname,): (I,)) -> Result<Self::Output, Self::Error> {
        self.setup_command(&self.bin)
            .arg(depotname)
            .stdout(Stdio::piped())
            .stderr(Stdio::piped())
            .spawn()
    }
}

impl<I: AsRef<OsStr>> ParameterizedSpawn<(I,)> for Depot<Delete> {
    type Output = Child;
    type Error = std::io::Error;

    /// Spawns `p4 depot -d [-f] depotname` with the given depot name as a
    /// child process with piped standard output and error streams; use the
    /// returned [`Child`] handle to wait for it or interact with it.
    fn spawn_with(&mut self, (depotname,): (I,)) -> Result<Self::Output, Self::Error> {
        self.setup_command(&self.bin)
            .arg(depotname)
            .stdout(Stdio::piped())
            .stderr(Stdio::piped())
            .spawn()
    }
}

impl<I: AsRef<OsStr>> ParameterizedSpawn<(I,)> for Depot<Stdout> {
    type Output = Child;
    type Error = std::io::Error;

    /// Spawns `p4 depot -o [-t type] depotname` with the given depot name as
    /// a child process with piped standard output and error streams; use the
    /// returned [`Child`] handle to wait for it or interact with it.
    fn spawn_with(&mut self, (depotname,): (I,)) -> Result<Self::Output, Self::Error> {
        self.setup_command(&self.bin)
            .arg(depotname)
            .stdout(Stdio::piped())
            .stderr(Stdio::piped())
            .spawn()
    }
}

impl ParameterizedSpawn<()> for Depot<Stdin> {
    type Output = Child;
    type Error = std::io::Error;

    /// Spawns `p4 depot -i` with a piped standard input stream (and piped
    /// standard output and error streams); write the depot specification to
    /// the returned [`Child`]'s stdin handle.
    fn spawn_with(&mut self, (): ()) -> Result<Self::Output, Self::Error> {
        self.setup_command(&self.bin)
            .stdin(Stdio::piped())
            .stdout(Stdio::piped())
            .stderr(Stdio::piped())
            .spawn()
    }
}

impl ParameterizedSpawn<(Stdio,)> for Depot<Stdin> {
    type Output = Child;
    type Error = std::io::Error;

    /// Spawns `p4 depot -i` with the given standard input configuration and
    /// piped standard output and error streams; use the returned [`Child`]
    /// handle to wait for it or interact with it.
    ///
    /// Pass `Stdio::piped()` to obtain a writable `child.stdin` handle and
    /// feed the depot specification into it; pass `Stdio::inherit()` to read
    /// the specification from the spawning process's own standard input.
    fn spawn_with(&mut self, (stdio,): (Stdio,)) -> Result<Self::Output, Self::Error> {
        self.setup_command(&self.bin)
            .stdin(stdio)
            .stdout(Stdio::piped())
            .stderr(Stdio::piped())
            .spawn()
    }
}

#[cfg(not(feature = "lt2015_2"))]
impl<I: AsRef<OsStr>> ParameterizedSpawn<(I,)> for Depot<Regular> {
    type Output = Child;
    type Error = std::io::Error;

    /// Spawns `p4 depot [-t type] depotname` with the given depot name as a
    /// child process with piped standard output and error streams; use the
    /// returned [`Child`] handle to wait for it or interact with it.
    fn spawn_with(&mut self, (depotname,): (I,)) -> Result<Self::Output, Self::Error> {
        self.setup_command(&self.bin)
            .arg(depotname)
            .stdout(Stdio::piped())
            .stderr(Stdio::piped())
            .spawn()
    }
}

impl Depot<Delete> {
    /// # Description
    ///
    /// -f
    ///
    /// By default, when you delete a depot, the directory specified by the
    #[cfg_attr(
        feature = "lt2014_2",
        doc = "`Map:` field (typically under `P4ROOT`) must be empty. Use the `-f` flag to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        all(feature = "lt2024_1", not(feature = "lt2014_2")),
        doc = "`Map:` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        all(feature = "lt2025_2", not(feature = "lt2024_1")),
        doc = "`Map` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        not(feature = "lt2025_2"),
        doc = "`Map` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty.",
        doc = "",
        doc = "The P4 Server will not delete files on disk if they are referenced elsewhere (due to being branched or integrated to another depot as a lazy copy). You should not remove referenced files from disk manually using operating system commands. For more information, see Deleting depots."
    )]
    pub fn get_force(&self) -> bool {
        self.mode.force
    }

    /// # Description
    ///
    /// -f
    ///
    /// By default, when you delete a depot, the directory specified by the
    #[cfg_attr(
        feature = "lt2014_2",
        doc = "`Map:` field (typically under `P4ROOT`) must be empty. Use the `-f` flag to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        all(feature = "lt2024_1", not(feature = "lt2014_2")),
        doc = "`Map:` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        all(feature = "lt2025_2", not(feature = "lt2024_1")),
        doc = "`Map` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        not(feature = "lt2025_2"),
        doc = "`Map` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty.",
        doc = "",
        doc = "The P4 Server will not delete files on disk if they are referenced elsewhere (due to being branched or integrated to another depot as a lazy copy). You should not remove referenced files from disk manually using operating system commands. For more information, see Deleting depots."
    )]
    pub fn set_force(&mut self, v: bool) -> &mut Self {
        self.mode.force = v;
        self
    }

    /// # Description
    ///
    /// -f
    ///
    /// By default, when you delete a depot, the directory specified by the
    #[cfg_attr(
        feature = "lt2014_2",
        doc = "`Map:` field (typically under `P4ROOT`) must be empty. Use the `-f` flag to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        all(feature = "lt2024_1", not(feature = "lt2014_2")),
        doc = "`Map:` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        all(feature = "lt2025_2", not(feature = "lt2024_1")),
        doc = "`Map` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty."
    )]
    #[cfg_attr(
        not(feature = "lt2025_2"),
        doc = "`Map` field (typically under `P4ROOT`) must be empty. Use the `-f` option to remove all files even if the directory is not empty.",
        doc = "",
        doc = "The P4 Server will not delete files on disk if they are referenced elsewhere (due to being branched or integrated to another depot as a lazy copy). You should not remove referenced files from disk manually using operating system commands. For more information, see Deleting depots."
    )]
    pub fn force(mut self, v: bool) -> Self {
        self.mode.force = v;
        self
    }
}

#[cfg(not(feature = "lt2015_2"))]
impl Depot<Regular> {
    /// # Description
    ///
    /// -t type
    ///
    /// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
    #[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
    #[cfg_attr(
        not(feature = "lt2017_1"),
        doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
    )]
    pub fn get_depot_type(&self) -> Option<DepotType> {
        self.mode.depot_type
    }

    /// # Description
    ///
    /// -t type
    ///
    /// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
    #[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
    #[cfg_attr(
        not(feature = "lt2017_1"),
        doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
    )]
    pub fn set_depot_type(&mut self, v: DepotType) -> &mut Self {
        self.mode.depot_type = Some(v);
        self
    }

    /// # Description
    ///
    /// -t type
    ///
    /// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
    #[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
    #[cfg_attr(
        not(feature = "lt2017_1"),
        doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
    )]
    pub fn depot_type(mut self, v: DepotType) -> Self {
        self.mode.depot_type = Some(v);
        self
    }

    /// # Description
    ///
    /// -o depotname
    ///
    /// Write a depot specification to standard output.
    ///
    /// Transitions this command to the [`Stdout`] mode, preserving the
    /// selected depot type.
    pub fn stdout(self) -> Depot<Stdout> {
        Depot {
            bin: self.bin,
            global_opts: self.global_opts,
            mode: Stdout {
                depot_type: self.mode.depot_type,
            },
        }
    }
}

impl Depot<Stdout> {
    /// # Description
    ///
    /// -t type
    ///
    /// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
    #[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
    #[cfg_attr(
        not(feature = "lt2017_1"),
        doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
    )]
    #[cfg(not(feature = "lt2015_2"))]
    pub fn get_depot_type(&self) -> Option<DepotType> {
        self.mode.depot_type
    }

    /// # Description
    ///
    /// -t type
    ///
    /// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
    #[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
    #[cfg_attr(
        not(feature = "lt2017_1"),
        doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
    )]
    #[cfg(not(feature = "lt2015_2"))]
    pub fn set_depot_type(&mut self, v: DepotType) -> &mut Self {
        self.mode.depot_type = Some(v);
        self
    }

    /// # Description
    ///
    /// -t type
    ///
    /// The type of the depot: `local`, `remote`, `spec`, `stream`, `unload`,
    #[cfg_attr(feature = "lt2017_1", doc = "`archive` or `tangent`.")]
    #[cfg_attr(
        not(feature = "lt2017_1"),
        doc = "`archive`, or `tangent`. To support Git workflows, a special type is `graph`."
    )]
    #[cfg(not(feature = "lt2015_2"))]
    pub fn depot_type(mut self, v: DepotType) -> Self {
        self.mode.depot_type = Some(v);
        self
    }
}

impl<M: ExclusiveOption> Depot<M> {
    /// Get the Perforce command path.
    pub fn get_bin(&self) -> &Path {
        &self.bin
    }

    /// Set the Perforce command path.
    pub fn set_bin(&mut self, bin: impl Into<PathBuf>) -> &mut Self {
        self.bin = bin.into();
        self
    }

    /// Set the Perforce command path.
    pub fn bin(mut self, bin: impl Into<PathBuf>) -> Self {
        self.set_bin(bin);
        self
    }

    /// # Description
    ///
    /// g-opts
    ///
    #[cfg_attr(
        feature = "lt2014_2",
        doc = "See the [Global Options](GlobalOpts) section."
    )]
    #[cfg_attr(
        all(feature = "lt2015_1", not(feature = "lt2014_2")),
        doc = "See the [“Global Options”](GlobalOpts) section."
    )]
    #[cfg_attr(
        all(feature = "lt2017_1", not(feature = "lt2015_1")),
        doc = "See [“Global Options”](GlobalOpts)."
    )]
    #[cfg_attr(
        all(feature = "lt2018_2", not(feature = "lt2017_1")),
        doc = "See [Global Options](GlobalOpts)."
    )]
    #[cfg_attr(not(feature = "lt2018_2"), doc = "See [Global options](GlobalOpts).")]
    pub fn get_global_opts(&self) -> &GlobalOpts {
        &self.global_opts
    }

    /// # Description
    ///
    /// g-opts
    ///
    #[cfg_attr(
        feature = "lt2014_2",
        doc = "See the [Global Options](GlobalOpts) section."
    )]
    #[cfg_attr(
        all(feature = "lt2015_1", not(feature = "lt2014_2")),
        doc = "See the [“Global Options”](GlobalOpts) section."
    )]
    #[cfg_attr(
        all(feature = "lt2017_1", not(feature = "lt2015_1")),
        doc = "See [“Global Options”](GlobalOpts)."
    )]
    #[cfg_attr(
        all(feature = "lt2018_2", not(feature = "lt2017_1")),
        doc = "See [Global Options](GlobalOpts)."
    )]
    #[cfg_attr(not(feature = "lt2018_2"), doc = "See [Global options](GlobalOpts).")]
    pub fn set_global_opts(&mut self, v: GlobalOpts) -> &mut Self {
        self.global_opts = v;
        self
    }

    /// # Description
    ///
    /// g-opts
    ///
    #[cfg_attr(
        feature = "lt2014_2",
        doc = "See the [Global Options](GlobalOpts) section."
    )]
    #[cfg_attr(
        all(feature = "lt2015_1", not(feature = "lt2014_2")),
        doc = "See the [“Global Options”](GlobalOpts) section."
    )]
    #[cfg_attr(
        all(feature = "lt2017_1", not(feature = "lt2015_1")),
        doc = "See [“Global Options”](GlobalOpts)."
    )]
    #[cfg_attr(
        all(feature = "lt2018_2", not(feature = "lt2017_1")),
        doc = "See [Global Options](GlobalOpts)."
    )]
    #[cfg_attr(not(feature = "lt2018_2"), doc = "See [Global options](GlobalOpts).")]
    pub fn global_opts(mut self, v: GlobalOpts) -> Self {
        self.global_opts = v;
        self
    }
}

impl<M: ExclusiveOption> SubCommand for Depot<M> {
    fn name(&self) -> &str {
        "depot"
    }

    fn inject_local_args(&self, command: &mut Command) {
        self.mode.inject_args(command);
    }

    fn global_opts(&self) -> Option<&GlobalOpts> {
        Some(&self.global_opts)
    }
}