From 0f05b836cbe373fdf31f97978f5d2d33407e8dae Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Mon, 13 Jul 2020 08:11:59 +0200 Subject: [PATCH] moved to slugifying filesnames --- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 1 + src/main.rs | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 78aa4ea..f858708 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,6 +110,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "deunicode" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" + [[package]] name = "dirs" version = "3.0.1" @@ -196,6 +202,7 @@ version = "0.0.0" dependencies = [ "chrono", "dirs", + "slug", "structopt", ] @@ -272,6 +279,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "slug" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" +dependencies = [ + "deunicode", +] + [[package]] name = "strsim" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index afd84dd..f33e51f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ edition = "2018" dirs = "3" structopt = "0.3" chrono = "0.4" +slug = "0.1" diff --git a/src/main.rs b/src/main.rs index d464546..8273551 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use dirs::home_dir; +use slug::slugify; use std::{fs, io, process}; use structopt::StructOpt; @@ -35,7 +36,7 @@ tags = {:?}{} } ); let output = output.trim(); - let path = dir.join(cli.title).with_extension("md"); + let path = dir.join(slugify(cli.title)).with_extension("md"); eprintln!("{}", path.display()); if path.exists() { eprintln!("path exists already, opening ...");