From 650e4d43714d8d97b3b1f155505f22f1872ae7bc Mon Sep 17 00:00:00 2001 From: James Tease Date: Tue, 16 May 2017 17:31:09 +0100 Subject: [PATCH 01/12] Commands for creating new files --- src/lib.rs | 2 +- src/main.rs | 73 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/new.rs | 27 ++++++++++++++++++++ 3 files changed, 94 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 599d58fc..4a18b45e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,7 +35,7 @@ extern crate lazy_static; pub use cobalt::build; pub use error::Error; pub use config::Config; -pub use new::create_new_project; +pub use new::{create_new_project, create_new_post, create_new_layout, create_new_page}; pub mod error; diff --git a/src/main.rs b/src/main.rs index 60d13082..8981053f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,8 @@ use env_logger::LogBuilder; use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use ghp::import_dir; -use cobalt::create_new_project; +use glob::Pattern; +use cobalt::{create_new_project, create_new_post, create_new_layout, create_new_page}; use notify::{Watcher, RecursiveMode, raw_watcher}; use std::sync::mpsc::channel; @@ -103,11 +104,22 @@ fn main() { .global(true) .takes_value(false)) .subcommand(SubCommand::with_name("init") - .about("create a new cobalt project") - .arg(Arg::with_name("DIRECTORY") - .help("Suppress all output") - .default_value("./") - .index(1))) + .about("create a new cobalt project") + .arg(Arg::with_name("DIRECTORY") + .help("Suppress all output") + .default_value("./") + .index(1))) + .subcommand(SubCommand::with_name("new") + .about("create a new post or file") + .arg(Arg::with_name("FILETYPE") + .help("Type of file to create eg post or layout") + .default_value("post") + .takes_value(true)) + .arg(Arg::with_name("FILENAME") + .help("File to create") + .default_value("new_post.md") + .takes_value(true))) + .subcommand(SubCommand::with_name("build") .about("build the cobalt project at the source dir") .arg(Arg::with_name("import") @@ -261,7 +273,54 @@ fn main() { std::process::exit(1); } } - } + }, + + "new" => { + let filetype = matches.value_of("FILETYPE").unwrap(); + let mut filename = matches.value_of("FILENAME").unwrap(); + println!("new called {:?} {:?}", filetype, filename); + + // TODO: fails if folder doesn't exist eg _layouts or posts + // TODO: allow user to specify templates + match filetype { + "layout" => { + if filename == "new_post.md" { + filename = "new_layout.liquid"; + } + match create_new_layout(&filename.to_string(), &config) { + Ok(_) => info!("Created new layout at {}{}/{}", &config.source, &config.layouts, filename), + Err(e) => { + error!("{}", e); + error!("Could not create a layout"); + std::process::exit(1); + } + } + }, + "page" => { + if filename == "new_post.md" { + filename = "new_page.md" + } + match create_new_page(&filename.to_string()) { + Ok(_) => info!("Created new page at {}", filename), + Err(e) => { + error!("{}", e); + error!("Could not create a page"); + std::process::exit(1); + } + } + }, + _ => { + match create_new_post(&filename.to_string(), &config) { + Ok(_) => info!("Created new post at {}{}/{}", &config.source, &config.posts, filename), + Err(e) => { + error!("{}", e); + error!("Could not create a new post"); + std::process::exit(1); + } + } + } + } + }, "build" => { build(&config); diff --git a/src/new.rs b/src/new.rs index 233d597e..40ea25e1 100644 --- a/src/new.rs +++ b/src/new.rs @@ -69,6 +69,7 @@ use std::path::Path; use std::fs::{DirBuilder, OpenOptions}; use std::io::Write; use error::Result; +use config::Config; pub fn create_new_project>(dest: P) -> Result<()> { let dest = dest.as_ref(); @@ -88,6 +89,32 @@ pub fn create_new_project>(dest: P) -> Result<()> { Ok(()) } +pub fn create_new_post(name: &String, config: &Config) -> Result<()> { + // TODO: check for extension or use default from config + // TODO: check if file already exists + let path = Path::new(&config.source); + let full_path = &path.join(&config.posts).join(name); + + try!(create_file(full_path, post_1_md)); + + Ok(()) +} + +pub fn create_new_layout(name: &String, config: &Config) -> Result<()> { + let path = Path::new(&config.source); + let full_path = &path.join(&config.layouts).join(name); + + try!(create_file(full_path, post_liquid)); + + Ok(()) +} + +pub fn create_new_page(name: &String) -> Result<()> { + try!(create_file(name, index_liquid)); + + Ok(()) +} + fn create_folder>(path: P) -> Result<()> { trace!("Creating folder {:?}", &path.as_ref()); From 38a62d698d1866504737634d056a854ce24f2c54 Mon Sep 17 00:00:00 2001 From: James Tease Date: Fri, 19 May 2017 09:22:14 +0100 Subject: [PATCH 02/12] Rm comments --- src/main.rs | 3 --- src/new.rs | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8981053f..deb0abc0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -278,10 +278,7 @@ fn main() { "new" => { let filetype = matches.value_of("FILETYPE").unwrap(); let mut filename = matches.value_of("FILENAME").unwrap(); - println!("new called {:?} {:?}", filetype, filename); - // TODO: fails if folder doesn't exist eg _layouts or posts - // TODO: allow user to specify templates match filetype { "layout" => { if filename == "new_post.md" { diff --git a/src/new.rs b/src/new.rs index 40ea25e1..6e088527 100644 --- a/src/new.rs +++ b/src/new.rs @@ -90,8 +90,6 @@ pub fn create_new_project>(dest: P) -> Result<()> { } pub fn create_new_post(name: &String, config: &Config) -> Result<()> { - // TODO: check for extension or use default from config - // TODO: check if file already exists let path = Path::new(&config.source); let full_path = &path.join(&config.posts).join(name); From d1cbd4231bab7cd0f21f21f5ea2bdf378b9fe333 Mon Sep 17 00:00:00 2001 From: James Tease Date: Fri, 19 May 2017 11:00:16 +0100 Subject: [PATCH 03/12] Lint errors --- src/main.rs | 14 ++++++++++---- src/new.rs | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index deb0abc0..d5d066bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -273,7 +273,7 @@ fn main() { std::process::exit(1); } } - }, + } "new" => { let filetype = matches.value_of("FILETYPE").unwrap(); @@ -285,7 +285,10 @@ fn main() { filename = "new_layout.liquid"; } match create_new_layout(&filename.to_string(), &config) { - Ok(_) => info!("Created new layout at {}{}/{}", &config.source, &config.layouts, filename), + Ok(_) => info!("Created new layout at {}{}/{}", + &config.source, + &config.layouts, + filename), Err(e) => { error!("{}", e); error!("Could not create a layout"); @@ -308,7 +311,10 @@ fn main() { }, _ => { match create_new_post(&filename.to_string(), &config) { - Ok(_) => info!("Created new post at {}{}/{}", &config.source, &config.posts, filename), + Ok(_) => info!("Created new post at {}{}/{}", + &config.source, + &config.posts, + filename), Err(e) => { error!("{}", e); error!("Could not create a new post"); @@ -317,7 +323,7 @@ fn main() { } } } - }, + } "build" => { build(&config); diff --git a/src/new.rs b/src/new.rs index 6e088527..106bbb2a 100644 --- a/src/new.rs +++ b/src/new.rs @@ -90,27 +90,27 @@ pub fn create_new_project>(dest: P) -> Result<()> { } pub fn create_new_post(name: &String, config: &Config) -> Result<()> { - let path = Path::new(&config.source); - let full_path = &path.join(&config.posts).join(name); + let path = Path::new(&config.source); + let full_path = &path.join(&config.posts).join(name); - try!(create_file(full_path, post_1_md)); + try!(create_file(full_path, post_1_md)); - Ok(()) + Ok(()) } pub fn create_new_layout(name: &String, config: &Config) -> Result<()> { - let path = Path::new(&config.source); - let full_path = &path.join(&config.layouts).join(name); + let path = Path::new(&config.source); + let full_path = &path.join(&config.layouts).join(name); - try!(create_file(full_path, post_liquid)); + try!(create_file(full_path, post_liquid)); - Ok(()) + Ok(()) } pub fn create_new_page(name: &String) -> Result<()> { - try!(create_file(name, index_liquid)); + try!(create_file(name, index_liquid)); - Ok(()) + Ok(()) } fn create_folder>(path: P) -> Result<()> { From f8b2e9f2adfa6ac23da8949ccb7dfe7d0d58de38 Mon Sep 17 00:00:00 2001 From: James Tease Date: Thu, 25 May 2017 17:17:48 +0100 Subject: [PATCH 04/12] Refactor create function and remove layout --- src/lib.rs | 2 +- src/main.rs | 57 +++++++++++------------------------------------------ src/new.rs | 38 +++++++++++++++++++---------------- 3 files changed, 34 insertions(+), 63 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4a18b45e..4ec710f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,7 +35,7 @@ extern crate lazy_static; pub use cobalt::build; pub use error::Error; pub use config::Config; -pub use new::{create_new_project, create_new_post, create_new_layout, create_new_page}; +pub use new::{create_new_project, create_new_document}; pub mod error; diff --git a/src/main.rs b/src/main.rs index d5d066bd..b1eb75e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use ghp::import_dir; use glob::Pattern; -use cobalt::{create_new_project, create_new_post, create_new_layout, create_new_page}; +use cobalt::{create_new_project, create_new_document}; use notify::{Watcher, RecursiveMode, raw_watcher}; use std::sync::mpsc::channel; @@ -117,7 +117,8 @@ fn main() { .takes_value(true)) .arg(Arg::with_name("FILENAME") .help("File to create") - .default_value("new_post.md") + .default_value_if("FILETYPE", Some("page"), "new_page.md") + .default_value_if("FILETYPE", Some("post"), "new_post.md") .takes_value(true))) .subcommand(SubCommand::with_name("build") @@ -277,50 +278,16 @@ fn main() { "new" => { let filetype = matches.value_of("FILETYPE").unwrap(); - let mut filename = matches.value_of("FILENAME").unwrap(); + let filename = matches.value_of("FILENAME").unwrap(); - match filetype { - "layout" => { - if filename == "new_post.md" { - filename = "new_layout.liquid"; - } - match create_new_layout(&filename.to_string(), &config) { - Ok(_) => info!("Created new layout at {}{}/{}", - &config.source, - &config.layouts, - filename), - Err(e) => { - error!("{}", e); - error!("Could not create a layout"); - std::process::exit(1); - } - } - }, - "page" => { - if filename == "new_post.md" { - filename = "new_page.md" - } - match create_new_page(&filename.to_string()) { - Ok(_) => info!("Created new page at {}", filename), - Err(e) => { - error!("{}", e); - error!("Could not create a page"); - std::process::exit(1); - } - } - }, - _ => { - match create_new_post(&filename.to_string(), &config) { - Ok(_) => info!("Created new post at {}{}/{}", - &config.source, - &config.posts, - filename), - Err(e) => { - error!("{}", e); - error!("Could not create a new post"); - std::process::exit(1); - } - } + match create_new_document(&filetype, &filename, &config) { + Ok(_) => info!("Created new {} {}", + filetype, + filename), + Err(e) => { + error!("{}", e); + error!("Could not create {}", filetype); + std::process::exit(1); } } } diff --git a/src/new.rs b/src/new.rs index 106bbb2a..e6b2e0ea 100644 --- a/src/new.rs +++ b/src/new.rs @@ -89,26 +89,30 @@ pub fn create_new_project>(dest: P) -> Result<()> { Ok(()) } -pub fn create_new_post(name: &String, config: &Config) -> Result<()> { +pub fn create_new_document(doc_type: &str, name: &str, config: &Config) -> Result<()> { let path = Path::new(&config.source); let full_path = &path.join(&config.posts).join(name); - try!(create_file(full_path, post_1_md)); - - Ok(()) -} - -pub fn create_new_layout(name: &String, config: &Config) -> Result<()> { - let path = Path::new(&config.source); - let full_path = &path.join(&config.layouts).join(name); - - try!(create_file(full_path, post_liquid)); - - Ok(()) -} - -pub fn create_new_page(name: &String) -> Result<()> { - try!(create_file(name, index_liquid)); + match doc_type { + "page" => { + println!("page exists? {:?}", Path::new(name).exists()); + // if !Path::new(name).exists() { + try!(create_file(name, index_liquid)) + // } else { + // return Err(); + // } + }, + "post" => { + println!("post exists? {:?}", Path::new(full_path).exists()); + + // if !Path::new(full_path).exists() { + try!(create_file(full_path, post_1_md)) + // } else { + // error!("here"); + // } + }, + _ => println!("Can only create post or page") + } Ok(()) } From 0f9c0c8103f352484e863c377488a3cab855b3ed Mon Sep 17 00:00:00 2001 From: James Tease Date: Fri, 26 May 2017 11:30:02 +0100 Subject: [PATCH 05/12] Error handling --- src/main.rs | 4 +--- src/new.rs | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index b1eb75e3..2c0bbfd4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -281,9 +281,7 @@ fn main() { let filename = matches.value_of("FILENAME").unwrap(); match create_new_document(&filetype, &filename, &config) { - Ok(_) => info!("Created new {} {}", - filetype, - filename), + Ok(_) => (), Err(e) => { error!("{}", e); error!("Could not create {}", filetype); diff --git a/src/new.rs b/src/new.rs index e6b2e0ea..9b782b4f 100644 --- a/src/new.rs +++ b/src/new.rs @@ -95,21 +95,22 @@ pub fn create_new_document(doc_type: &str, name: &str, config: &Config) -> Resul match doc_type { "page" => { - println!("page exists? {:?}", Path::new(name).exists()); - // if !Path::new(name).exists() { - try!(create_file(name, index_liquid)) - // } else { - // return Err(); - // } + match Path::new(name).exists() { + false => { + info!("Created new {} {}", doc_type, name); + try!(create_file(name, index_liquid)) + }, + true => error!("{} already exists", name) + }; }, "post" => { - println!("post exists? {:?}", Path::new(full_path).exists()); - - // if !Path::new(full_path).exists() { - try!(create_file(full_path, post_1_md)) - // } else { - // error!("here"); - // } + match Path::new(full_path).exists() { + false => { + info!("Created new {} {}", doc_type, name); + try!(create_file(full_path, post_1_md)) + }, + true => error!("{} already exists", name) + }; }, _ => println!("Can only create post or page") } From 956f57875a27251b3462d7aaadcdff9c212bbbea Mon Sep 17 00:00:00 2001 From: James Tease Date: Fri, 26 May 2017 14:19:47 +0100 Subject: [PATCH 06/12] Simplfy errors with create_new --- src/main.rs | 7 ++++--- src/new.rs | 27 +++++++-------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2c0bbfd4..23892958 100644 --- a/src/main.rs +++ b/src/main.rs @@ -277,11 +277,12 @@ fn main() { } "new" => { - let filetype = matches.value_of("FILETYPE").unwrap(); - let filename = matches.value_of("FILENAME").unwrap(); + // TODO: 'cobalt new nonsense' + unwrap = crash so provide default again + let filetype = matches.value_of("FILETYPE").unwrap_or("post"); + let filename = matches.value_of("FILENAME").unwrap_or("new_post.md"); match create_new_document(&filetype, &filename, &config) { - Ok(_) => (), + Ok(_) => info!("Created new {} {}", filetype, filename), Err(e) => { error!("{}", e); error!("Could not create {}", filetype); diff --git a/src/new.rs b/src/new.rs index 9b782b4f..351debf0 100644 --- a/src/new.rs +++ b/src/new.rs @@ -94,24 +94,8 @@ pub fn create_new_document(doc_type: &str, name: &str, config: &Config) -> Resul let full_path = &path.join(&config.posts).join(name); match doc_type { - "page" => { - match Path::new(name).exists() { - false => { - info!("Created new {} {}", doc_type, name); - try!(create_file(name, index_liquid)) - }, - true => error!("{} already exists", name) - }; - }, - "post" => { - match Path::new(full_path).exists() { - false => { - info!("Created new {} {}", doc_type, name); - try!(create_file(full_path, post_1_md)) - }, - true => error!("{} already exists", name) - }; - }, + "page" => create_file(name, index_liquid)?, + "post" => create_file(full_path, post_1_md)?, _ => println!("Can only create post or page") } @@ -129,9 +113,12 @@ fn create_folder>(path: P) -> Result<()> { fn create_file>(name: P, content: &[u8]) -> Result<()> { trace!("Creating file {:?}", &name.as_ref()); - let mut file = try!(OpenOptions::new().write(true).create(true).open(name)); + let mut file = try!(OpenOptions::new() + .write(true) + .create_new(true) + .open(name)); - try!(file.write_all(content)); + file.write_all(content)?; Ok(()) } From ad1dc2bc0ef7be422e5add80d328ac3daef99eb3 Mon Sep 17 00:00:00 2001 From: James Tease Date: Fri, 26 May 2017 15:18:55 +0100 Subject: [PATCH 07/12] Improve errors and default arguments --- src/main.rs | 7 +++---- src/new.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 23892958..baab38a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,7 +118,7 @@ fn main() { .arg(Arg::with_name("FILENAME") .help("File to create") .default_value_if("FILETYPE", Some("page"), "new_page.md") - .default_value_if("FILETYPE", Some("post"), "new_post.md") + .default_value("new_post.md") .takes_value(true))) .subcommand(SubCommand::with_name("build") @@ -277,9 +277,8 @@ fn main() { } "new" => { - // TODO: 'cobalt new nonsense' + unwrap = crash so provide default again - let filetype = matches.value_of("FILETYPE").unwrap_or("post"); - let filename = matches.value_of("FILENAME").unwrap_or("new_post.md"); + let filetype = matches.value_of("FILETYPE").unwrap(); + let filename = matches.value_of("FILENAME").unwrap(); match create_new_document(&filetype, &filename, &config) { Ok(_) => info!("Created new {} {}", filetype, filename), diff --git a/src/new.rs b/src/new.rs index 351debf0..87d07ae1 100644 --- a/src/new.rs +++ b/src/new.rs @@ -96,7 +96,7 @@ pub fn create_new_document(doc_type: &str, name: &str, config: &Config) -> Resul match doc_type { "page" => create_file(name, index_liquid)?, "post" => create_file(full_path, post_1_md)?, - _ => println!("Can only create post or page") + _ => bail!("Can only create post or page") } Ok(()) From 48111d1fcf862c711a3c711e0dcb326fcb14548a Mon Sep 17 00:00:00 2001 From: James Tease Date: Fri, 26 May 2017 15:21:00 +0100 Subject: [PATCH 08/12] Better bail message --- src/new.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/new.rs b/src/new.rs index 87d07ae1..9297e640 100644 --- a/src/new.rs +++ b/src/new.rs @@ -96,7 +96,7 @@ pub fn create_new_document(doc_type: &str, name: &str, config: &Config) -> Resul match doc_type { "page" => create_file(name, index_liquid)?, "post" => create_file(full_path, post_1_md)?, - _ => bail!("Can only create post or page") + _ => bail!("Unsupported document type {}", doc_type) } Ok(()) From 14e395e9891cb380fc70be7390b0e57142a438cf Mon Sep 17 00:00:00 2001 From: James Tease Date: Fri, 26 May 2017 15:22:43 +0100 Subject: [PATCH 09/12] Improve help message --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index baab38a9..dc22e40a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,9 +110,9 @@ fn main() { .default_value("./") .index(1))) .subcommand(SubCommand::with_name("new") - .about("create a new post or file") + .about("Create a new post or page") .arg(Arg::with_name("FILETYPE") - .help("Type of file to create eg post or layout") + .help("Type of file to create eg post or page") .default_value("post") .takes_value(true)) .arg(Arg::with_name("FILENAME") From e2b26c299713ddcd9ca3ec4b358e00ed9ceb58e7 Mon Sep 17 00:00:00 2001 From: James Tease Date: Tue, 6 Jun 2017 09:09:57 +0100 Subject: [PATCH 10/12] Rebase --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index dc22e40a..ead84553 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,6 @@ use env_logger::LogBuilder; use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use ghp::import_dir; -use glob::Pattern; use cobalt::{create_new_project, create_new_document}; use notify::{Watcher, RecursiveMode, raw_watcher}; From 3c1f8763a783036203c82aff806bfbf333e13642 Mon Sep 17 00:00:00 2001 From: James Tease Date: Tue, 6 Jun 2017 09:31:24 +0100 Subject: [PATCH 11/12] Fix lint --- src/main.rs | 30 +++++++++++++++--------------- src/new.rs | 8 ++++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index ead84553..f32edfcc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,22 +103,22 @@ fn main() { .global(true) .takes_value(false)) .subcommand(SubCommand::with_name("init") - .about("create a new cobalt project") - .arg(Arg::with_name("DIRECTORY") - .help("Suppress all output") - .default_value("./") - .index(1))) + .about("create a new cobalt project") + .arg(Arg::with_name("DIRECTORY") + .help("Suppress all output") + .default_value("./") + .index(1))) .subcommand(SubCommand::with_name("new") - .about("Create a new post or page") - .arg(Arg::with_name("FILETYPE") - .help("Type of file to create eg post or page") - .default_value("post") - .takes_value(true)) - .arg(Arg::with_name("FILENAME") - .help("File to create") - .default_value_if("FILETYPE", Some("page"), "new_page.md") - .default_value("new_post.md") - .takes_value(true))) + .about("Create a new post or page") + .arg(Arg::with_name("FILETYPE") + .help("Type of file to create eg post or page") + .default_value("post") + .takes_value(true)) + .arg(Arg::with_name("FILENAME") + .help("File to create") + .default_value_if("FILETYPE", Some("page"), "new_page.md") + .default_value("new_post.md") + .takes_value(true))) .subcommand(SubCommand::with_name("build") .about("build the cobalt project at the source dir") diff --git a/src/new.rs b/src/new.rs index 9297e640..20ed79ba 100644 --- a/src/new.rs +++ b/src/new.rs @@ -96,7 +96,7 @@ pub fn create_new_document(doc_type: &str, name: &str, config: &Config) -> Resul match doc_type { "page" => create_file(name, index_liquid)?, "post" => create_file(full_path, post_1_md)?, - _ => bail!("Unsupported document type {}", doc_type) + _ => bail!("Unsupported document type {}", doc_type), } Ok(()) @@ -114,9 +114,9 @@ fn create_file>(name: P, content: &[u8]) -> Result<()> { trace!("Creating file {:?}", &name.as_ref()); let mut file = try!(OpenOptions::new() - .write(true) - .create_new(true) - .open(name)); + .write(true) + .create_new(true) + .open(name)); file.write_all(content)?; From b9c3b726cba815df85e76e07b9595f56c25c2b2f Mon Sep 17 00:00:00 2001 From: James Tease Date: Tue, 6 Jun 2017 09:48:08 +0100 Subject: [PATCH 12/12] Lint --- src/main.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index f32edfcc..8ea75c05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,21 +105,22 @@ fn main() { .subcommand(SubCommand::with_name("init") .about("create a new cobalt project") .arg(Arg::with_name("DIRECTORY") - .help("Suppress all output") - .default_value("./") - .index(1))) + .help("Suppress all output") + .default_value("./") + .index(1))) .subcommand(SubCommand::with_name("new") .about("Create a new post or page") .arg(Arg::with_name("FILETYPE") - .help("Type of file to create eg post or page") - .default_value("post") - .takes_value(true)) + .help("Type of file to create eg post or page") + .default_value("post") + .takes_value(true)) .arg(Arg::with_name("FILENAME") - .help("File to create") - .default_value_if("FILETYPE", Some("page"), "new_page.md") - .default_value("new_post.md") - .takes_value(true))) - + .help("File to create") + .default_value_if("FILETYPE", + Some("page"), + "new_page.md") + .default_value("new_post.md") + .takes_value(true))) .subcommand(SubCommand::with_name("build") .about("build the cobalt project at the source dir") .arg(Arg::with_name("import")