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
use crate::prelude::*;
use caesura_macros::Options;
use serde::{Deserialize, Serialize};
/// Options for upload
#[derive(Options, Clone, Debug, Deserialize, Serialize)]
pub struct UploadOptions {
/// Should the transcoded files be copied to the content directory?
#[arg(long)]
pub copy_transcode_to_content_dir: bool,
/// Directory the transcoded files are copied to.
///
/// This should be set if you wish to auto-add to your torrent client.
#[arg(long)]
pub copy_transcode_to: Option<PathBuf>,
/// Directory the torrent file is copied to.
///
/// This should be set if you wish to auto-add to your torrent client.
#[arg(long)]
pub copy_torrent_to: Option<PathBuf>,
/// Is this a dry run?
///
/// If enabled data won't be uploaded and will instead be printed to the console.
#[arg(long)]
pub dry_run: bool,
}
impl OptionsContract for UploadOptions {
type Partial = UploadOptionsPartial;
fn validate(&self, errors: &mut Vec<OptionRule>) {
if let Some(dir) = &self.copy_transcode_to
&& !dir.is_dir()
{
errors.push(DoesNotExist(
"Copy transcode to directory".to_owned(),
dir.to_string_lossy().to_string(),
));
}
if let Some(dir) = &self.copy_torrent_to
&& !dir.is_dir()
{
errors.push(DoesNotExist(
"Copy torrent to directory".to_owned(),
dir.to_string_lossy().to_string(),
));
}
}
}