diff options
author | Sam Tay <sam.chong.tay@gmail.com> | 2020-07-02 23:50:34 -0700 |
---|---|---|
committer | Sam Tay <sam.chong.tay@gmail.com> | 2020-07-02 23:50:34 -0700 |
commit | e332a12eca11d8af61df75a388eed72e73324f89 (patch) | |
tree | 818a4e90a6b0919f768bdf2ed3a8ea6ee5ca0d9c | |
parent | 483e0a7c3f66e3ec0590d58719461ef5bd1c6887 (diff) |
Remove dead code & comments
-rw-r--r-- | src/cli.rs | 6 | ||||
-rw-r--r-- | src/config.rs | 2 | ||||
-rw-r--r-- | src/stackexchange/scraper.rs | 5 | ||||
-rw-r--r-- | src/term.rs | 48 | ||||
-rw-r--r-- | src/tui/enumerable.rs | 12 | ||||
-rw-r--r-- | src/tui/mod.rs | 2 | ||||
-rw-r--r-- | src/tui/ui.rs | 0 |
7 files changed, 5 insertions, 70 deletions
@@ -4,7 +4,6 @@ use crate::config; use crate::config::Config; use crate::error::Result; -// TODO --sites plural // TODO --add-site (in addition to defaults) pub struct Opts { pub list_sites: bool, @@ -127,5 +126,6 @@ pub fn get_opts() -> Result<Opts> { }) } -// TODO how can I test this App given https://users.rust-lang.org/t/help-with-idiomatic-rust-and-ownership-semantics/43880 -// Maybe pass get_opts a closure that produces the Config... +// TODO how can I test this App given +// https://users.rust-lang.org/t/help-with-idiomatic-rust-and-ownership-semantics/43880 +// Maybe pass get_opts a closure that produces the Config...? diff --git a/src/config.rs b/src/config.rs index 79caa28..1a22bb0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,7 +9,7 @@ use crate::error::{Error, Result}; use crate::utils; #[derive(Deserialize, Serialize, Debug, Clone)] -#[serde(rename_all = "lowercase")] // TODO test this +#[serde(rename_all = "lowercase")] pub enum SearchEngine { DuckDuckGo, Google, diff --git a/src/stackexchange/scraper.rs b/src/stackexchange/scraper.rs index cdb34d6..e67f0f6 100644 --- a/src/stackexchange/scraper.rs +++ b/src/stackexchange/scraper.rs @@ -86,8 +86,6 @@ impl Scraper for Google { limit: u16, ) -> Result<ScrapedData> { let anchors = Selector::parse("div.r > a").unwrap(); - // TODO detect no results - // TODO detect blocked request parse_with_selector(anchors, html, sites, limit) } @@ -130,7 +128,6 @@ where q } -// TODO Benchmark this. It would likely be faster to use regex on the decoded url. fn parse_with_selector( anchors: Selector, html: &str, @@ -193,6 +190,7 @@ fn question_url_to_id(site_url: &str, input: &str) -> Option<String> { } // TODO Get blocked google request html +// TODO Get google no results html // note: this may only be possible at search.rs level (with non-200 code) #[cfg(test)] mod tests { @@ -357,7 +355,6 @@ mod tests { assert_eq!(question_url_to_id(site_url, input), None); // Different site - // TODO get this to pass; then test tagged.html let site_url = "meta.stackexchange.com"; let input = "/l/?kh=-1&uddg=https://math.meta.stackexchange.com/q/11828270"; assert_eq!(question_url_to_id(site_url, input), None); diff --git a/src/term.rs b/src/term.rs index 9ad880b..fab35f5 100644 --- a/src/term.rs +++ b/src/term.rs @@ -161,51 +161,3 @@ macro_rules! print_notice { Ok::<(), Error>(()) }}; } - -#[macro_export] -macro_rules! print_success { - ($skin: expr, $md: literal $(, $value: expr )* $(,)? ) => {{ - use lazy_static::lazy_static; - use minimad::mad_inline; - use crate::error::Error; - let err = &mut std::io::stderr(); - let p = $skin.paragraph.clone(); - $skin.paragraph.set_fg(crossterm::style::Color::Green); - termimad::mad_write_inline!(err, $skin, "✔ ").map_err(Error::from)?; - $skin.write_composite(err, mad_inline!($md $(, $value)*)).map_err(Error::from)?; - $skin.paragraph = p; - Ok::<(), Error>(()) - }}; -} - -#[macro_export] -macro_rules! print_log { - ($skin: expr, $md: literal $(, $value: expr )* $(,)? ) => {{ - use lazy_static::lazy_static; - use minimad::mad_inline; - use crate::error::Error; - let err = &mut std::io::stderr(); - let p = $skin.paragraph.clone(); - $skin.paragraph.set_fg(crossterm::style::Color::Blue); - termimad::mad_write_inline!(err, $skin, "• ").map_err(Error::from)?; - $skin.write_composite(err, mad_inline!($md $(, $value)*)).map_err(Error::from)?; - $skin.paragraph = p; - Ok::<(), Error>(()) - }}; -} - -#[macro_export] -macro_rules! print_warn { - ($skin: expr, $md: literal $(, $value: expr )* $(,)? ) => {{ - use lazy_static::lazy_static; - use minimad::mad_inline; - use crate::error::Error; - let err = &mut std::io::stderr(); - let p = $skin.paragraph.clone(); - $skin.paragraph.set_fg(crossterm::style::Color::Magenta); - termimad::mad_write_inline!(err, $skin, "⚡").map_err(Error::from)?; - $skin.write_composite(err, mad_inline!($md $(, $value)*)).map_err(Error::from)?; - $skin.paragraph = p; - Ok::<(), Error>(()) - }}; -} diff --git a/src/tui/enumerable.rs b/src/tui/enumerable.rs deleted file mode 100644 index 2b31dc9..0000000 --- a/src/tui/enumerable.rs +++ /dev/null @@ -1,12 +0,0 @@ -/// Borrowed from Haskell -/// Should be possible to auto derive -pub trait Enum: Sized { - fn to_enum(&self) -> u8; - fn from_enum(i: u8) -> Self; - fn succ(&self) -> Self { - Self::from_enum(self.to_enum() + 1) - } - fn pred(&self) -> Self { - Self::from_enum(self.to_enum() - 1) - } -} diff --git a/src/tui/mod.rs b/src/tui/mod.rs index 3b9a557..9bdd9da 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -1,7 +1,5 @@ mod app; -mod enumerable; pub mod markdown; -mod ui; mod views; pub use app::run; diff --git a/src/tui/ui.rs b/src/tui/ui.rs deleted file mode 100644 index e69de29..0000000 --- a/src/tui/ui.rs +++ /dev/null |