mirror of
https://github.com/alexpasmantier/television.git
synced 2025-07-28 22:01:39 +00:00
feat(cli): add --force
option to update-channels
This commit is contained in:
parent
16d7de7d09
commit
99b5c5ce78
@ -482,7 +482,11 @@ pub enum Command {
|
||||
},
|
||||
/// Downloads the latest collection of default channel prototypes from github
|
||||
/// and saves them to the local configuration directory.
|
||||
UpdateChannels,
|
||||
UpdateChannels {
|
||||
/// Force update on already existing channels.
|
||||
#[arg(long, default_value = "false")]
|
||||
force: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, ValueEnum)]
|
||||
|
@ -120,7 +120,7 @@ fn get_default_prototypes_from_repo() -> Result<Vec<DownloadedPrototype>> {
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub fn update_local_channels() -> Result<()> {
|
||||
pub fn update_local_channels(force: &bool) -> Result<()> {
|
||||
println!("{}", "Fetching latest cable channels...".bold());
|
||||
let default_prototypes = get_default_prototypes_from_repo()?;
|
||||
println!("{}", "\nSaving channels locally...".bold());
|
||||
@ -133,7 +133,7 @@ pub fn update_local_channels() -> Result<()> {
|
||||
let file_path =
|
||||
cable_path.join(&p.name).with_extension(CHANNEL_FILE_FORMAT);
|
||||
// if the file already exists, don't overwrite it
|
||||
if file_path.exists() {
|
||||
if file_path.exists() && !force {
|
||||
println!(
|
||||
" Channel {} already exists at {}, SKIPPING...",
|
||||
p.name.blue().bold(),
|
||||
|
@ -241,8 +241,8 @@ pub fn handle_subcommand(command: &Command, config: &Config) -> Result<()> {
|
||||
println!("{script}");
|
||||
exit(0);
|
||||
}
|
||||
Command::UpdateChannels => {
|
||||
update_local_channels()?;
|
||||
Command::UpdateChannels { force } => {
|
||||
update_local_channels(force)?;
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user