chore: rustfmt with nightly options ♻️

This commit is contained in:
Dheepak Krishnamurthy 2023-08-28 23:31:27 -04:00
parent ae44577979
commit bc0c3f10a6
16 changed files with 168 additions and 189 deletions

View file

@ -1,94 +1,64 @@
use crate::calendar::Calendar;
use crate::completion::{get_start_word_under_cursor, CompletionList};
use crate::config;
use crate::config::Config;
use crate::event::Event;
use crate::help::Help;
use crate::keyconfig::KeyConfig;
use crate::scrollbar::Scrollbar;
use crate::table::{Row, Table, TableMode, TableState};
use crate::task_report::TaskReportTable;
use crate::ui;
use crate::utils;
use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
use std::fs;
use std::path::Path;
use std::io::Read;
use std::io::Write;
use std::time::SystemTime;
use ratatui::symbols::bar::FULL;
use task_hookrs::date::Date;
use task_hookrs::import::import;
use task_hookrs::status::TaskStatus;
use task_hookrs::task::Task;
use uuid::Uuid;
use unicode_segmentation::Graphemes;
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
use chrono::{DateTime, Datelike, FixedOffset, Local, NaiveDate, NaiveDateTime, TimeZone, Timelike};
use anyhow::Context as AnyhowContext;
use anyhow::{anyhow, Result};
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use ratatui::{
backend::Backend,
layout::{Alignment, Constraint, Direction, Layout, Margin, Rect},
style::{Color, Modifier, Style},
terminal::Frame,
text::{Line, Span, Text},
widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Wrap},
use std::{
borrow::Borrow,
cmp::Ordering,
collections::{HashMap, HashSet},
convert::TryInto,
fs, io,
io::{Read, Write},
path::Path,
sync::{mpsc, Arc, Mutex},
time::{Duration, Instant, SystemTime},
};
use std::time::Duration;
use rustyline::history::SearchDirection as HistoryDirection;
use rustyline::line_buffer::LineBuffer;
use rustyline::At;
use rustyline::Editor;
use rustyline::Word;
use crate::history::HistoryContext;
use ratatui::{backend::CrosstermBackend, Terminal};
use std::io;
use regex::Regex;
use lazy_static::lazy_static;
use crate::action::Action;
use crate::event::KeyCode;
use crate::pane::context::{ContextDetails, ContextsState};
use crate::pane::project::ProjectsState;
use crate::pane::Pane;
use crossterm::style::style;
use anyhow::{anyhow, Context as AnyhowContext, Result};
use chrono::{DateTime, Datelike, FixedOffset, Local, NaiveDate, NaiveDateTime, TimeZone, Timelike};
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
execute,
style::style,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use futures::SinkExt;
use std::borrow::Borrow;
use std::time::Instant;
use task_hookrs::project::Project;
use lazy_static::lazy_static;
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use ratatui::{
backend::{Backend, CrosstermBackend},
layout::{Alignment, Constraint, Direction, Layout, Margin, Rect},
style::{Color, Modifier, Style},
symbols::bar::FULL,
terminal::Frame,
text::{Line, Span, Text},
widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Tabs, Wrap},
Terminal,
};
use regex::Regex;
use rustyline::{history::SearchDirection as HistoryDirection, line_buffer::LineBuffer, At, Editor, Word};
use task_hookrs::{date::Date, import::import, project::Project, status::TaskStatus, task::Task};
use unicode_segmentation::{Graphemes, UnicodeSegmentation};
use unicode_width::UnicodeWidthStr;
use uuid::Uuid;
use versions::Versioning;
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use ratatui::widgets::Tabs;
use crate::{
action::Action,
calendar::Calendar,
completion::{get_start_word_under_cursor, CompletionList},
config,
config::Config,
event::{Event, KeyCode},
help::Help,
history::HistoryContext,
keyconfig::KeyConfig,
pane::{
context::{ContextDetails, ContextsState},
project::ProjectsState,
Pane,
},
scrollbar::Scrollbar,
table::{Row, Table, TableMode, TableState},
task_report::TaskReportTable,
ui, utils,
};
const MAX_LINE: usize = 4096;
@ -3731,13 +3701,11 @@ pub fn remove_tag(task: &mut Task, tag: &str) {
#[cfg(test)]
mod tests {
use std::{ffi::OsStr, fmt::Write, fs::File, io, path::Path};
use ratatui::{backend::TestBackend, buffer::Buffer};
use super::*;
use ratatui::backend::TestBackend;
use ratatui::buffer::Buffer;
use std::ffi::OsStr;
use std::fs::File;
use std::path::Path;
use std::{fmt::Write, io};
/// Returns a string representation of the given buffer for debugging purpose.
fn buffer_view(buffer: &Buffer) -> String {

View file

@ -5,8 +5,9 @@ use std::fmt;
const COL_WIDTH: usize = 21;
use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use std::cmp::min;
use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use ratatui::{
buffer::Buffer,
layout::Rect,
@ -15,8 +16,6 @@ use ratatui::{
widgets::{Block, Widget},
};
use std::cmp::min;
#[derive(Debug, Clone)]
pub struct Calendar<'a> {
pub block: Option<Block<'a>>,

View file

@ -1,3 +1,5 @@
use std::{error::Error, io};
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use ratatui::{
layout::{Constraint, Corner, Direction, Layout},
@ -6,16 +8,15 @@ use ratatui::{
widgets::{Block, Borders, List, ListItem, ListState},
Terminal,
};
use std::{error::Error, io};
use rustyline::highlight::{Highlighter, MatchingBracketHighlighter};
use rustyline::hint::Hinter;
use rustyline::line_buffer::LineBuffer;
use rustyline::Context;
use rustyline::{error::ReadlineError, history::FileHistory};
use unicode_segmentation::Graphemes;
use unicode_segmentation::UnicodeSegmentation;
use rustyline::{
error::ReadlineError,
highlight::{Highlighter, MatchingBracketHighlighter},
hint::Hinter,
history::FileHistory,
line_buffer::LineBuffer,
Context,
};
use unicode_segmentation::{Graphemes, UnicodeSegmentation};
use unicode_width::UnicodeWidthStr;
pub fn get_start_word_under_cursor(line: &str, cursor_pos: usize) -> usize {

View file

@ -1,12 +1,10 @@
use std::{collections::HashMap, error::Error, str};
use anyhow::{Context, Result};
use ratatui::{
style::{Color, Modifier, Style},
symbols::bar::FULL,
symbols::line::DOUBLE_VERTICAL,
symbols::{bar::FULL, line::DOUBLE_VERTICAL},
};
use std::collections::HashMap;
use std::error::Error;
use std::str;
trait TaskWarriorBool {
fn get_bool(&self) -> Option<bool>;

View file

@ -1,12 +1,13 @@
use crossterm::event::KeyEvent;
use crossterm::event::{
KeyCode::{BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, Home, Insert, Left, Null, PageDown, PageUp, Right, Tab, Up, F},
KeyEvent, KeyModifiers,
};
use futures::StreamExt;
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use serde::{Deserialize, Serialize};
use tokio::{sync::mpsc, sync::oneshot, task::JoinHandle};
use crossterm::event::{
KeyCode::{BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, Home, Insert, Left, Null, PageDown, PageUp, Right, Tab, Up, F},
KeyModifiers,
use tokio::{
sync::{mpsc, oneshot},
task::JoinHandle,
};
#[derive(Debug, Clone, Copy)]

View file

@ -1,10 +1,13 @@
use std::{
fs::File,
path::{Path, PathBuf},
};
use anyhow::{anyhow, Result};
use rustyline::error::ReadlineError;
use rustyline::history::DefaultHistory;
use rustyline::history::History;
use rustyline::history::SearchDirection;
use std::fs::File;
use std::path::{Path, PathBuf};
use rustyline::{
error::ReadlineError,
history::{DefaultHistory, History, SearchDirection},
};
pub struct HistoryContext {
history: DefaultHistory,

View file

@ -1,9 +1,9 @@
use crate::event::KeyCode;
use std::{collections::HashSet, error::Error, hash::Hash};
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::error::Error;
use std::hash::Hash;
use crate::event::KeyCode;
#[derive(Serialize, Deserialize, Debug)]
pub struct KeyConfig {

View file

@ -20,18 +20,17 @@ mod task_report;
mod ui;
mod utils;
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use log4rs::append::file::FileAppender;
use log4rs::config::{Appender, Config, Logger, Root};
use log4rs::encode::pattern::PatternEncoder;
use std::env;
use std::error::Error;
use std::io::{self, Write};
use std::panic;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::{
env,
error::Error,
io::{self, Write},
panic,
path::{Path, PathBuf},
time::Duration,
};
use anyhow::Result;
use app::{Mode, TaskwarriorTui};
use crossterm::{
cursor,
event::{DisableMouseCapture, EnableMouseCapture, EventStream},
@ -39,15 +38,16 @@ use crossterm::{
terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen},
};
use futures::stream::{FuturesUnordered, StreamExt};
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use log4rs::{
append::file::FileAppender,
config::{Appender, Config, Logger, Root},
encode::pattern::PatternEncoder,
};
use path_clean::PathClean;
use ratatui::{backend::CrosstermBackend, Terminal};
use path_clean::PathClean;
use app::{Mode, TaskwarriorTui};
use crate::action::Action;
use crate::event::Event;
use crate::keyconfig::KeyConfig;
use crate::{action::Action, event::Event, keyconfig::KeyConfig};
const LOG_PATTERN: &str = "{d(%Y-%m-%d %H:%M:%S)} | {l} | {f}:{L} | {m}{n}";

View file

@ -1,14 +1,22 @@
use anyhow::Context as AnyhowContext;
use anyhow::{anyhow, Result};
use std::fmt;
use anyhow::{anyhow, Context as AnyhowContext, Result};
const NAME: &str = "Name";
const TYPE: &str = "Remaining";
const DEFINITION: &str = "Avg age";
const ACTIVE: &str = "Complete";
use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use std::{
cmp,
cmp::min,
collections::{HashMap, HashSet},
error::Error,
process::{Command, Output},
};
use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use itertools::Itertools;
use ratatui::{
buffer::Buffer,
layout::{Alignment, Rect},
@ -17,20 +25,16 @@ use ratatui::{
text::{Line, Span, Text},
widgets::{Block, BorderType, Borders, Clear, Paragraph, StatefulWidget, Widget},
};
use crate::action::Action;
use crate::app::{Mode, TaskwarriorTui};
use crate::event::KeyCode;
use crate::pane::Pane;
use crate::table::TableState;
use itertools::Itertools;
use std::cmp;
use std::cmp::min;
use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::process::{Command, Output};
use uuid::Uuid;
use crate::{
action::Action,
app::{Mode, TaskwarriorTui},
event::KeyCode,
pane::Pane,
table::TableState,
};
#[derive(Debug, Clone, Default)]
pub struct ContextDetails {
pub name: String,

View file

@ -1,9 +1,12 @@
use std::ops::Index;
use anyhow::Result;
use crate::action::Action;
use crate::app::{Mode, TaskwarriorTui};
use crate::event::KeyCode;
use std::ops::Index;
use crate::{
action::Action,
app::{Mode, TaskwarriorTui},
event::KeyCode,
};
pub mod context;
pub mod project;

View file

@ -1,15 +1,22 @@
use anyhow::Context as AnyhowContext;
use anyhow::{anyhow, Result};
use std::fmt;
use anyhow::{anyhow, Context as AnyhowContext, Result};
const COL_WIDTH: usize = 21;
const PROJECT_HEADER: &str = "Name";
const REMAINING_TASK_HEADER: &str = "Remaining";
const AVG_AGE_HEADER: &str = "Avg age";
const COMPLETE_HEADER: &str = "Complete";
use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use std::{
cmp::min,
collections::{HashMap, HashSet},
error::Error,
process::{Command, Output},
};
use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use itertools::Itertools;
use ratatui::{
buffer::Buffer,
layout::Rect,
@ -17,21 +24,18 @@ use ratatui::{
symbols,
widgets::{Block, Widget},
};
use crate::action::Action;
use crate::app::{Mode, TaskwarriorTui};
use crate::event::KeyCode;
use crate::pane::Pane;
use crate::table::TableState;
use crate::utils::Changeset;
use itertools::Itertools;
use std::cmp::min;
use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::process::{Command, Output};
use task_hookrs::project::Project;
use uuid::Uuid;
use crate::{
action::Action,
app::{Mode, TaskwarriorTui},
event::KeyCode,
pane::Pane,
table::TableState,
utils::Changeset,
};
pub struct ProjectsState {
pub(crate) list: Vec<Project>,
pub table_state: TableState,

View file

@ -1,7 +1,13 @@
use std::{
collections::{HashMap, HashSet},
fmt::Display,
iter::{self, Iterator},
};
use cassowary::{
strength::{MEDIUM, REQUIRED, WEAK},
Expression, Solver,
WeightedRelation::{EQ, GE, LE},
{Expression, Solver},
};
use ratatui::{
buffer::Buffer,
@ -9,14 +15,7 @@ use ratatui::{
style::Style,
widgets::{Block, StatefulWidget, Widget},
};
use std::collections::HashSet;
use std::{
collections::HashMap,
fmt::Display,
iter::{self, Iterator},
};
use unicode_segmentation::Graphemes;
use unicode_segmentation::UnicodeSegmentation;
use unicode_segmentation::{Graphemes, UnicodeSegmentation};
use unicode_width::UnicodeWidthStr;
#[derive(Debug, Clone)]

View file

@ -1,10 +1,9 @@
use std::{error::Error, process::Command};
use anyhow::Result;
use chrono::{DateTime, Datelike, Local, NaiveDate, NaiveDateTime, TimeZone};
use itertools::join;
use std::error::Error;
use std::process::Command;
use task_hookrs::task::Task;
use task_hookrs::uda::UDAValue;
use task_hookrs::{task::Task, uda::UDAValue};
use unicode_truncate::UnicodeTruncateStr;
use unicode_width::UnicodeWidthStr;

View file

@ -1,6 +1,4 @@
use rustyline::line_buffer::ChangeListener;
use rustyline::line_buffer::DeleteListener;
use rustyline::line_buffer::Direction;
use rustyline::line_buffer::{ChangeListener, DeleteListener, Direction};
/// Undo manager
#[derive(Default)]