summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-05-23 08:34:22 +0000
committerLars Wirzenius <liw@liw.fi>2021-05-23 08:34:22 +0000
commit96c269190104ce3be4ecb071352d129ace9ea93a (patch)
treecb61a5cdb47c007eb66ce61e645b42d064b85512
parent4bf43dc56719df211b111d5a71f28c0d0e14b922 (diff)
parenta19f4254b73cc981e0559a2c5e1ac7c214fdfe4e (diff)
downloadjt2-96c269190104ce3be4ecb071352d129ace9ea93a.tar.gz
Merge branch 'fixes' into 'main'
chore: fix clippy warnings, use new Subplot binary name See merge request larswirzenius/jt!17
-rwxr-xr-xcheck6
-rw-r--r--src/bin/jt2.rs9
-rw-r--r--src/cmd.rs4
-rw-r--r--src/config.rs2
-rw-r--r--src/journal.rs11
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<PathBuf, JournalError> {
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<Local> = DateTime::from(now);
+ let now: DateTime<Local> = Local::now();
now.to_rfc2822()
}