From a19f4254b73cc981e0559a2c5e1ac7c214fdfe4e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 23 May 2021 11:32:48 +0300 Subject: chore: fix clippy warnings, use new Subplot binary name --- check | 6 +++--- src/bin/jt2.rs | 9 +++------ src/cmd.rs | 4 +++- src/config.rs | 2 +- src/journal.rs | 11 +++++------ 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/check b/check index 55b9158..c90afee 100755 --- a/check +++ b/check @@ -33,10 +33,10 @@ $hideok cargo test $hideok cargo fmt -- --check $hideok find . -type f -name '*.py' ! -name test.py -exec black --check '{}' + -$hideok sp-docgen jt.md --output jt.html -$hideok sp-docgen jt.md --output jt.pdf +$hideok subplot docgen jt.md --output jt.html +$hideok subplot docgen jt.md --output jt.pdf -$hideok sp-codegen jt.md --output test.py +$hideok subplot codegen jt.md --output test.py rm -f test.log $hideok python3 test.py --log test.log "$@" diff --git a/src/bin/jt2.rs b/src/bin/jt2.rs index a8fe6c1..c37b799 100644 --- a/src/bin/jt2.rs +++ b/src/bin/jt2.rs @@ -4,12 +4,9 @@ use jt2::opt::{Opt, SubCommand}; use structopt::StructOpt; fn main() { - match do_work() { - Err(err) => { - eprintln!("ERROR: {:?}", err); - std::process::exit(1); - } - Ok(_) => (), + if let Err(err) = do_work() { + eprintln!("ERROR: {:?}", err); + std::process::exit(1); } } diff --git a/src/cmd.rs b/src/cmd.rs index c1606e0..da917ee 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -36,7 +36,9 @@ pub struct IsJournal {} impl IsJournal { pub fn run(&self, config: &Configuration) -> Result<(), JournalError> { if !Journal::is_journal(&config.dirname, &config.entries) { - return Err(JournalError::NotAJournal(config.dirname.display().to_string()).into()); + return Err(JournalError::NotAJournal( + config.dirname.display().to_string(), + )); } Ok(()) } diff --git a/src/config.rs b/src/config.rs index e40c35f..655b835 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,7 +28,7 @@ impl InputConfiguration { .map_err(|err| JournalError::ReadConfig(filename.to_path_buf(), err))?; let config = serde_yaml::from_slice(&text) .map_err(|err| JournalError::ConfigSyntax(filename.to_path_buf(), err))?; - return Ok(config); + Ok(config) } } diff --git a/src/journal.rs b/src/journal.rs index 2610a44..8042f83 100644 --- a/src/journal.rs +++ b/src/journal.rs @@ -105,19 +105,19 @@ impl Journal { return Ok(pathname); } } - return Err(JournalError::TooManyDrafts( + Err(JournalError::TooManyDrafts( MAX_DRAFT_COUNT, dirname.to_path_buf(), - )); + )) } pub fn pick_draft(&self, id: &str) -> Result { let drafts = self.drafts(); let filename = drafts.join(format!("{}.md", id)); if filename.exists() { - return Ok(filename); + Ok(filename) } else { - return Err(JournalError::NoSuchDraft(id.to_string(), self.drafts())); + Err(JournalError::NoSuchDraft(id.to_string(), self.drafts())) } } @@ -206,7 +206,6 @@ fn topic_path(dirname: &Path, topic: &Path) -> PathBuf { } fn current_timestamp() -> String { - let now = Local::now(); - let now: DateTime = DateTime::from(now); + let now: DateTime = Local::now(); now.to_rfc2822() } -- cgit v1.2.1