feat: add getter methods
- instead of making fields public
This commit is contained in:
40
src/lib.rs
40
src/lib.rs
@@ -15,7 +15,7 @@ pub struct Args {
|
|||||||
help = "Comma-separated list of video file paths",
|
help = "Comma-separated list of video file paths",
|
||||||
required = true
|
required = true
|
||||||
)]
|
)]
|
||||||
pub videos: String,
|
videos: String,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
short = 'i',
|
short = 'i',
|
||||||
@@ -24,7 +24,7 @@ pub struct Args {
|
|||||||
help = "Time interval between uploads (e.g., 2h, 30m, 1d)",
|
help = "Time interval between uploads (e.g., 2h, 30m, 1d)",
|
||||||
required = true
|
required = true
|
||||||
)]
|
)]
|
||||||
pub interval: String,
|
interval: String,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
short = 'c',
|
short = 'c',
|
||||||
@@ -34,7 +34,7 @@ pub struct Args {
|
|||||||
default_value = "~/.client_secrets.json",
|
default_value = "~/.client_secrets.json",
|
||||||
required = true
|
required = true
|
||||||
)]
|
)]
|
||||||
pub oauth_config: String,
|
oauth_config: String,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
short = 'm',
|
short = 'm',
|
||||||
@@ -42,7 +42,7 @@ pub struct Args {
|
|||||||
value_name = "METADATA_FILE",
|
value_name = "METADATA_FILE",
|
||||||
help = "JSON file containing video metadata"
|
help = "JSON file containing video metadata"
|
||||||
)]
|
)]
|
||||||
pub metadata: Option<String>,
|
metadata: Option<String>,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
short = 's',
|
short = 's',
|
||||||
@@ -50,21 +50,47 @@ pub struct Args {
|
|||||||
value_name = "START_TIME",
|
value_name = "START_TIME",
|
||||||
help = "Start time for first upload (ISO 8601 format)"
|
help = "Start time for first upload (ISO 8601 format)"
|
||||||
)]
|
)]
|
||||||
pub start_time: Option<String>,
|
start_time: Option<String>,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
long = "timestamp-file",
|
long = "timestamp-file",
|
||||||
value_name = "FILE",
|
value_name = "FILE",
|
||||||
help = "File containing unix timestamp for start time"
|
help = "File containing unix timestamp for start time"
|
||||||
)]
|
)]
|
||||||
pub timestamp_file: Option<String>,
|
timestamp_file: Option<String>,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
long = "dry-run",
|
long = "dry-run",
|
||||||
help = "Show schedule without uploading",
|
help = "Show schedule without uploading",
|
||||||
action = clap::ArgAction::SetTrue
|
action = clap::ArgAction::SetTrue
|
||||||
)]
|
)]
|
||||||
pub dry_run: bool,
|
dry_run: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Args {
|
||||||
|
pub fn timestamp_file(&self) -> Option<&String> {
|
||||||
|
self.timestamp_file.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn videos(&self) -> &str {
|
||||||
|
&self.videos
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn interval(&self) -> &str {
|
||||||
|
&self.interval
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dry_run(&self) -> bool {
|
||||||
|
self.dry_run
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start_time(&self) -> Option<&String> {
|
||||||
|
self.start_time.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn oauth_config(&self) -> &str {
|
||||||
|
&self.oauth_config
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_duration(duration_str: &str) -> Result<Duration, Box<dyn std::error::Error>> {
|
pub fn parse_duration(duration_str: &str) -> Result<Duration, Box<dyn std::error::Error>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user