more documentation
This commit is contained in:
parent
c92bb3b31b
commit
7453bb8cae
|
|
@ -5,7 +5,6 @@ use chrono::Datelike;
|
|||
use comrak::nodes::{AstNode, NodeValue};
|
||||
use comrak::parse_document;
|
||||
use comrak::{Arena, ComrakExtensionOptions, ComrakOptions, ComrakParseOptions};
|
||||
use log;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::{read, File};
|
||||
use std::io::Write;
|
||||
|
|
@ -25,8 +24,9 @@ pub fn get_filepath(data_dir: &PathBuf, date: &NaiveDate) -> PathBuf {
|
|||
file_path
|
||||
}
|
||||
|
||||
// generate strings from TaskGroups and date
|
||||
/// generate strings from TaskGroups and date
|
||||
pub fn generate_file_content(data: &Vec<TaskGroup>, date: &NaiveDate) -> String {
|
||||
// TODO: This should be a type and then I can implement it with From<>
|
||||
let mut content = format!(
|
||||
"# Today's tasks {}-{:02}-{:02}\n",
|
||||
date.year(),
|
||||
|
|
@ -46,6 +46,7 @@ pub fn write_file(path: &PathBuf, content: &String) {
|
|||
|
||||
/// Load in text file as String
|
||||
pub fn load_file(file: &TodoFile) -> String {
|
||||
// TODO: This could be a TryFrom<>
|
||||
let contents_utf8 = read(file.file.clone())
|
||||
.expect(format!("Could not read file {}", file.file.to_string_lossy()).as_str());
|
||||
str::from_utf8(&contents_utf8)
|
||||
|
|
|
|||
14
src/main.rs
14
src/main.rs
|
|
@ -19,6 +19,7 @@ use std::path::Path;
|
|||
use std::process::Command;
|
||||
use todo::{File as TodoFile, TaskGroup};
|
||||
|
||||
// TODO: add options to use specific date instead of args.previous
|
||||
fn main() {
|
||||
// setup
|
||||
let args = Args::parse();
|
||||
|
|
@ -100,11 +101,18 @@ fn main() {
|
|||
let closest_files = TodoFile::get_closest_files(files.collect(), target, args.number);
|
||||
// list files
|
||||
if args.list {
|
||||
closest_files
|
||||
.into_iter()
|
||||
.for_each(|f| println!("{}", f.file.canonicalize().unwrap().to_string_lossy()));
|
||||
println!("Today - n\tFile");
|
||||
closest_files.into_iter().for_each(|f| {
|
||||
println!(
|
||||
"{}\t\t{}",
|
||||
(today - f.date).num_days(),
|
||||
f.file.canonicalize().unwrap().to_string_lossy(),
|
||||
)
|
||||
});
|
||||
return ();
|
||||
}
|
||||
// TODO: If the user did not pick a date that exist they should have the
|
||||
// option to updated their choice
|
||||
|
||||
let latest_file = closest_files.first();
|
||||
let current_file = match latest_file {
|
||||
|
|
|
|||
Loading…
Reference in New Issue