diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-18 22:55:09 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-18 22:55:09 -0400 |
commit | 06b2d7730d10240b471e859c7988ed219aa4c590 (patch) | |
tree | f5dcca189bb2d79c4def09540eec73cdb832c6b8 /src/commands/sort.rs | |
parent | f3081669e488c54ab4fcae2829ea2f58f082c6e7 (diff) |
remove cursormovestub and add rudimentary sort command
Diffstat (limited to 'src/commands/sort.rs')
-rw-r--r-- | src/commands/sort.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/commands/sort.rs b/src/commands/sort.rs new file mode 100644 index 0000000..935e7fd --- /dev/null +++ b/src/commands/sort.rs @@ -0,0 +1,39 @@ +use std::path; + +use crate::commands::{JoshutoCommand, JoshutoRunnable}; +use crate::context::JoshutoContext; +use crate::error::JoshutoResult; +use crate::ui::TuiBackend; + +use crate::sort::SortType; + +use crate::HOME_DIR; + +#[derive(Clone, Debug)] +pub struct Sort { + sort_method: SortType, +} + +impl Sort { + pub fn new(sort_method: SortType) -> Self { + Self { sort_method } + } + pub const fn command() -> &'static str { + "sort" + } +} + +impl JoshutoCommand for Sort {} + +impl std::fmt::Display for Sort { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(Self::command()) + } +} + +impl JoshutoRunnable for Sort { + fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + context.config_t.sort_option.sort_method = self.sort_method; + Ok(()) + } +} |