Playlist with multiple, mixed items

Prior to this commit, projects/playlists were limited to folders even if
file URLs were passed as arguments. With this commit both files and
folders are added to projects from the command line.

This doesn't affect opening a file from the GUI yet, but this patch
implements the required plumbing for that as well.
This commit is contained in:
Josh Megnauth 2025-02-11 02:08:10 -05:00 committed by Jeremy Soller
parent 3fd8641df2
commit 701fc818f7
2 changed files with 71 additions and 7 deletions

View file

@ -8,8 +8,10 @@ use url::Url;
#[derive(Debug, Default)]
pub struct Arguments {
/// URLs to play with associated metadata
pub urls: Vec<Url>,
/// Files or directory URLs to play
pub urls: Option<Vec<Url>>,
/// Single URL only
pub url_opt: Option<Url>,
}
impl Arguments {
@ -31,7 +33,17 @@ impl Arguments {
warn!("Unused argument: {arg:?}");
}
Ok(Arguments { urls })
if urls.len() > 1 {
Ok(Arguments {
urls: Some(urls),
..Default::default()
})
} else {
Ok(Arguments {
url_opt: urls.into_iter().next(),
..Default::default()
})
}
}
}