Fix clippy lints
This commit is contained in:
parent
1826a839e7
commit
d30563648c
6 changed files with 11 additions and 21 deletions
7
notes.md
7
notes.md
|
|
@ -1,5 +1,8 @@
|
||||||
# Things to do next
|
# Things to do next
|
||||||
- `check` complains about some of the defaults. Make sure default settings conform with opinions of `check`
|
- `check` complains about some of the defaults. Make sure default settings conform with opinions of `check`
|
||||||
|
- refactor to move functionality like rofi to shell scripts
|
||||||
|
Instead provide more scriptable functionality
|
||||||
|
- actual config instead of hardcoding values
|
||||||
|
|
||||||
# Things to think about
|
# Things to think about
|
||||||
- Do I want to copy templates when creating a course?
|
- Do I want to copy templates when creating a course?
|
||||||
|
|
@ -7,13 +10,11 @@
|
||||||
- sometimes I don't need them
|
- sometimes I don't need them
|
||||||
- annoying to do by hand
|
- annoying to do by hand
|
||||||
- I don't know either way when creating the course
|
- I don't know either way when creating the course
|
||||||
- Move `course.toml` to `.course.toml`?
|
|
||||||
- git doesn't automatically track hidden files I think (both pro and con)
|
|
||||||
|
|
||||||
# Things to do, if you are bored
|
# Things to do, if you are bored
|
||||||
- Think about better parsing for Courses (semester)
|
- Think about better parsing for Courses (semester)
|
||||||
- Think about better error handling
|
- Think about better error handling
|
||||||
- probably implement “bubbling up” of errors using the `?` operator
|
|
||||||
- Think about better code separation/organization
|
- Think about better code separation/organization
|
||||||
|
|
||||||
# Things learned
|
# Things learned
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,8 @@ pub struct Config {
|
||||||
pub note_extensions: Vec<String>,
|
pub note_extensions: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt, Default)]
|
||||||
pub struct ListOptions {
|
pub struct ListOptions {
|
||||||
#[structopt(short, long)]
|
#[structopt(short, long)]
|
||||||
pub all: bool,
|
pub all: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ListOptions {
|
|
||||||
fn default() -> Self {
|
|
||||||
ListOptions { all: false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ impl Course {
|
||||||
let mut coursestring = String::new();
|
let mut coursestring = String::new();
|
||||||
handle = File::open(&path).unwrap();
|
handle = File::open(&path).unwrap();
|
||||||
handle.read_to_string(&mut coursestring).unwrap();
|
handle.read_to_string(&mut coursestring).unwrap();
|
||||||
let mut course: Course = toml::from_str(&coursestring).expect(&format!("{:?}", &path));
|
let mut course: Course = toml::from_str(&coursestring)?;
|
||||||
course.path = path.parent().unwrap().to_path_buf();
|
course.path = path.parent().unwrap().to_path_buf();
|
||||||
if options.all || course.is_current() {
|
if options.all || course.is_current() {
|
||||||
courses.push(course);
|
courses.push(course);
|
||||||
|
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -116,16 +116,12 @@ fn list_lectures(conf: &Config, options: ListOptions) -> Result<Vec<PathBuf>> {
|
||||||
|
|
||||||
let lectures = lectures?
|
let lectures = lectures?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|path| {
|
.filter(|path| {
|
||||||
if let Some(ext) = path.extension() {
|
if let Some(ext) = path.extension() {
|
||||||
let ext = ext.to_owned().to_string_lossy().into();
|
let ext = ext.to_owned().to_string_lossy().into();
|
||||||
if conf.note_extensions.contains(&ext) {
|
conf.note_extensions.contains(&ext)
|
||||||
Some(path)
|
|
||||||
} else {
|
} else {
|
||||||
None
|
false
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ pub fn select_meeting(conf: &Config, options: &ListOptions) -> Result<()> {
|
||||||
let meetings: Vec<_> = Course::list(conf, options)?
|
let meetings: Vec<_> = Course::list(conf, options)?
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|c: Course| {
|
.flat_map(|c: Course| {
|
||||||
if let Some(meetings) = c.meetings() {
|
if let Some(meetings) = c.meetings() {
|
||||||
meetings.clone()
|
meetings.clone()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -30,7 +30,6 @@ pub fn select_meeting(conf: &Config, options: &ListOptions) -> Result<()> {
|
||||||
.map(move |m| (c.clone(), m.clone()))
|
.map(move |m| (c.clone(), m.clone()))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
.collect();
|
.collect();
|
||||||
let meeting_names: Vec<_> = meetings
|
let meeting_names: Vec<_> = meetings
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
pub fn to_snail_case(from: impl Into<String>) -> String {
|
pub fn to_snail_case(from: impl Into<String>) -> String {
|
||||||
from.into().replace(" ", "_").to_lowercase()
|
from.into().replace(' ', "_").to_lowercase()
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn to_title_case(from: &str) -> String {
|
// pub fn to_title_case(from: &str) -> String {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue