Skip to content

Commit a06ff0d

Browse files
committed
Add ability to download all themes.
1 parent 07d3555 commit a06ff0d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/main.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ use resource::{
4040
use site::Site;
4141
use theme::{Theme, ThemeConfig};
4242

43+
const ALL_THEMES_URL: &str =
44+
"https://github.com/servus-social/themes/releases/latest/download/all-themes.zip";
4345
const DEFAULT_THEMES_URL: &str =
4446
"https://github.com/servus-social/themes/releases/latest/download/themes.zip";
4547

@@ -971,14 +973,25 @@ fn load_or_download_themes(root_path: &str, url: &str) -> HashMap<String, Theme>
971973

972974
let stdin = io::stdin();
973975
let mut response = String::new();
974-
while response != "n" && response != "y" {
975-
print!("Fetch themes from {}? [y/n]? ", url);
976+
while response != "n" && response != "y" && response != "a" {
977+
print!(
978+
"Fetch themes?\n[Y]es fetch {}\n[A]ll fetch {}\n[N]o\nYour choice: ",
979+
url, ALL_THEMES_URL
980+
);
976981
io::stdout().flush().unwrap();
977982
response = stdin.lock().lines().next().unwrap().unwrap().to_lowercase();
978983
}
979984

980-
if response == "y" {
981-
if let Err(e) = download_themes(root_path, url) {
985+
let download_url = if response == "y" {
986+
Some(url)
987+
} else if response == "a" {
988+
Some(ALL_THEMES_URL)
989+
} else {
990+
None
991+
};
992+
993+
if let Some(download_url) = download_url {
994+
if let Err(e) = download_themes(root_path, download_url) {
982995
panic!("Failed to fetch themes: {}", e);
983996
}
984997

0 commit comments

Comments
 (0)