aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock20
-rw-r--r--Cargo.toml2
-rw-r--r--src/archive.rs8
-rw-r--r--src/renderer.rs5
-rw-r--r--src/themes.rs13
5 files changed, 29 insertions, 19 deletions
diff --git a/Cargo.lock b/Cargo.lock
index db2959b..dec9413 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -781,6 +781,8 @@ dependencies = [
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)",
"yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1342,6 +1344,22 @@ dependencies = [
]
[[package]]
+name = "strum"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "strum_macros"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "syn"
version = "0.15.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2029,6 +2047,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1"
"checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6"
+"checksum strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f"
+"checksum strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e"
"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c2167ff53da2a661702b3299f71a91b61b1dffef36b4b2884b1f9c67254c0133"
diff --git a/Cargo.toml b/Cargo.toml
index 5384ee7..94b7455 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -43,3 +43,5 @@ futures = "0.1.26"
libflate = "0.1.21"
failure = "0.1.5"
log = "0.4.6"
+strum = "0.15.0"
+strum_macros = "0.15.0" \ No newline at end of file
diff --git a/src/archive.rs b/src/archive.rs
index b1119f0..f588d56 100644
--- a/src/archive.rs
+++ b/src/archive.rs
@@ -6,11 +6,12 @@ use serde::Deserialize;
use std::io;
use std::path::PathBuf;
use tar::Builder;
+use strum_macros::EnumIter;
use crate::errors;
/// Available compression methods
-#[derive(Debug, Deserialize, Clone)]
+#[derive(Debug, Deserialize, Clone, EnumIter)]
pub enum CompressionMethod {
/// TAR GZ
#[serde(alias = "targz")]
@@ -25,11 +26,6 @@ impl CompressionMethod {
.to_string()
}
- /// Lists compression methods
- pub fn get_compression_methods() -> Vec<Self> {
- vec![CompressionMethod::TarGz]
- }
-
pub fn extension(&self) -> String {
match &self {
CompressionMethod::TarGz => "tar.gz",
diff --git a/src/renderer.rs b/src/renderer.rs
index 2d6fd88..1371ab6 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -2,6 +2,7 @@ use chrono::{DateTime, Duration, Utc};
use chrono_humanize::{Accuracy, HumanTime, Tense};
use maud::{html, Markup, PreEscaped, DOCTYPE};
use std::time::SystemTime;
+use strum::IntoEnumIterator;
use crate::archive;
use crate::listing;
@@ -36,7 +37,7 @@ pub fn page(
h1.title { (page_title) }
div.toolbar {
div.download {
- @for compression_method in archive::CompressionMethod::get_compression_methods() {
+ @for compression_method in archive::CompressionMethod::iter() {
(archive_button(compression_method))
}
}
@@ -98,7 +99,7 @@ fn color_scheme_selector(
"Change theme..."
}
ul {
- @for color_scheme in themes::ColorScheme::get_color_schemes() {
+ @for color_scheme in themes::ColorScheme::iter() {
@if active_color_scheme.get_name() == color_scheme.get_name() {
li.active {
(color_scheme_link(&sort_method, &sort_order, &color_scheme))
diff --git a/src/themes.rs b/src/themes.rs
index dca656d..8635c8f 100644
--- a/src/themes.rs
+++ b/src/themes.rs
@@ -1,8 +1,9 @@
use serde::Deserialize;
use structopt::clap::{_clap_count_exprs, arg_enum};
+use strum_macros::EnumIter;
arg_enum! {
- #[derive(Debug, Deserialize, Clone)]
+ #[derive(Debug, Deserialize, Clone, EnumIter)]
#[serde(rename_all = "lowercase")]
pub enum ColorScheme {
Archlinux,
@@ -45,16 +46,6 @@ impl ColorScheme {
.to_string()
}
- /// Lists available color schemes
- pub fn get_color_schemes() -> Vec<Self> {
- vec![
- ColorScheme::Archlinux,
- ColorScheme::Zenburn,
- ColorScheme::Monokai,
- ColorScheme::Squirrel,
- ]
- }
-
/// Retrieves the color palette associated to a color scheme
pub fn get_theme(self) -> Theme {
match self {