Browse Source

Removed dbg!s, used log

master
Julio Biason 5 years ago
parent
commit
c9d6714eb6
  1. 105
      Cargo.lock
  2. 2
      Cargo.toml
  3. 2
      README.md
  4. 7
      src/args/validators.rs
  5. 14
      src/main.rs

105
Cargo.lock generated

@ -1,5 +1,14 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
[[package]]
name = "aho-corasick"
version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.11.0" version = "0.11.0"
@ -64,6 +73,19 @@ dependencies = [
"vec_map", "vec_map",
] ]
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.1.14" version = "0.1.14"
@ -84,12 +106,42 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "humantime"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
dependencies = [
"quick-error",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.67" version = "0.2.67"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
[[package]]
name = "log"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.42" version = "0.1.42"
@ -124,6 +176,12 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.3" version = "1.0.3"
@ -180,6 +238,24 @@ version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "regex"
version = "1.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
name = "regex-syntax"
version = "0.6.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.104" version = "1.0.104"
@ -214,6 +290,15 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "termcolor"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.11.0" version = "0.11.0"
@ -223,6 +308,15 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "thread_local"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.42" version = "0.1.42"
@ -249,6 +343,8 @@ version = "0.1.0"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",
"env_logger",
"log",
"serde", "serde",
"serde_derive", "serde_derive",
"toml", "toml",
@ -304,6 +400,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"

2
Cargo.toml

@ -12,3 +12,5 @@ serde = "*"
serde_derive = "*" serde_derive = "*"
toml = "0.5" toml = "0.5"
uuid = { version = "0.8", features = ["v4"] } uuid = { version = "0.8", features = ["v4"] }
log = "*"
env_logger = "0.7.1"

2
README.md

@ -27,7 +27,7 @@ tell you that you have 15 days up to it.
- [ ] Sort events by ETA - [ ] Sort events by ETA
- [ ] Option to remove events - [ ] Option to remove events
- [ ] Move the app "db" to a fixed space - [ ] Move the app "db" to a fixed space
- [ ] Replace `dbg!` with [env_logger](https://crates.io/crates/env_logger) - [x] Replace `dbg!` with [env_logger](https://crates.io/crates/env_logger)
(reasoning: Although `dbg!` is nice and dandy, it can't be disabled, and (reasoning: Although `dbg!` is nice and dandy, it can't be disabled, and
that's bad UI) that's bad UI)
- [ ] Remove `unwrap()`s (for example, in the argument parsing). - [ ] Remove `unwrap()`s (for example, in the argument parsing).

7
src/args/validators.rs

@ -17,10 +17,12 @@
*/ */
use chrono::prelude::*; use chrono::prelude::*;
use log;
pub fn date(input: String) -> Result<(), String> { pub fn date(input: String) -> Result<(), String> {
let fake_datetime = format!("{} 00:00:00", input); let fake_datetime = format!("{} 00:00:00", input);
if let Ok(_) = dbg!(Utc.datetime_from_str(&fake_datetime, "%Y-%m-%d %H:%M:%S")) { if let Ok(parse) = Utc.datetime_from_str(&fake_datetime, "%Y-%m-%d %H:%M:%S") {
log::debug!("Parsing {} ({})= {:?}", input, fake_datetime, parse);
Ok(()) Ok(())
} else { } else {
Err(format!("Invalid date: '{}'", input)) Err(format!("Invalid date: '{}'", input))
@ -29,7 +31,8 @@ pub fn date(input: String) -> Result<(), String> {
pub fn time(input: String) -> Result<(), String> { pub fn time(input: String) -> Result<(), String> {
let fake_datetime = format!("2020-01-01 {}:00", input); let fake_datetime = format!("2020-01-01 {}:00", input);
if let Ok(_) = dbg!(Utc.datetime_from_str(&fake_datetime, "%Y-%m-%d %H:%M:%S")) { if let Ok(parse) = Utc.datetime_from_str(&fake_datetime, "%Y-%m-%d %H:%M:%S") {
log::debug!("Parsing {} ({}) = {:?}", input, fake_datetime, parse);
Ok(()) Ok(())
} else { } else {
Err(format!("Invalid time: '{}'", input)) Err(format!("Invalid time: '{}'", input))

14
src/main.rs

@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
use log;
mod args; mod args;
mod eventlist; mod eventlist;
@ -23,7 +25,10 @@ use crate::eventlist::event::Event;
use crate::eventlist::eventlist::EventList; use crate::eventlist::eventlist::EventList;
fn main() { fn main() {
if let Ok(command) = dbg!(args::parse()) { env_logger::init();
if let Ok(command) = args::parse() {
log::debug!("Command: {:?}", command);
match command { match command {
args::Action::List => list(), args::Action::List => list(),
args::Action::Add(description, date) => add_with_date(&description, &date), args::Action::Add(description, date) => add_with_date(&description, &date),
@ -41,7 +46,12 @@ fn list() {
fn add_with_date(description: &str, date: &str) { fn add_with_date(description: &str, date: &str) {
let event = Event::new_on_date(description, date); let event = Event::new_on_date(description, date);
let mut event_list = dbg!(EventList::load()); println!("Adding event {}", event);
let mut event_list = EventList::load();
log::debug!("EventList: {:?}", event_list);
event_list.push(event); event_list.push(event);
event_list.save(); event_list.save();
println!("Done.");
} }

Loading…
Cancel
Save