Skip to content

Commit

Permalink
Move structs and enums from types to config module
Browse files Browse the repository at this point in the history
  • Loading branch information
bensadeh committed Oct 13, 2024
1 parent 24d2f4e commit c2f7de2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 43 deletions.
42 changes: 39 additions & 3 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::cli::Cli;
use crate::types::{
Config, Error, FolderInfo, Input, Output, PathAndLineCount, GENERAL_ERROR, MISUSE_SHELL_BUILTIN, OK,
};
use color_eyre::owo_colors::OwoColorize;
use std::fs;
use std::fs::{DirEntry, File};
Expand Down Expand Up @@ -212,3 +209,42 @@ fn count_lines<P: AsRef<Path>>(file_path: P) -> usize {

reader.lines().count()
}

pub const OK: i32 = 0;
pub const GENERAL_ERROR: i32 = 1;
pub const MISUSE_SHELL_BUILTIN: i32 = 2;

pub struct Error {
pub exit_code: i32,
pub message: String,
}

pub struct Config {
pub input: Input,
pub output: Output,
pub follow: bool,
pub start_at_end: bool,
}

pub struct PathAndLineCount {
pub path: String,
pub line_count: usize,
}

pub struct FolderInfo {
pub folder_name: String,
pub file_paths: Vec<String>,
}

pub enum Input {
File(PathAndLineCount),
Folder(FolderInfo),
Command(String),
Stdin,
}

pub enum Output {
TempFile,
Stdout,
Suppress,
}
2 changes: 1 addition & 1 deletion src/io/controller/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_trait::async_trait;
use tokio::io;

use crate::config::{Config, Input, Output};
use crate::io::presenter::empty::NoPresenter;
use crate::io::presenter::less::Less;
use crate::io::presenter::Present;
Expand All @@ -12,7 +13,6 @@ use crate::io::writer::dummy::NoWriter;
use crate::io::writer::stdout::StdoutWriter;
use crate::io::writer::temp_file::TempFile;
use crate::io::writer::AsyncLineWriter;
use crate::types::{Config, Input, Output};
use tokio::sync::oneshot::Sender;

pub struct Io {
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod config;
mod highlighter_builder;
mod io;
mod theme;
mod types;

use crate::cli::keywords::get_keywords_from_cli;
use crate::cli::{completions, Cli};
Expand Down
38 changes: 0 additions & 38 deletions src/types.rs

This file was deleted.

0 comments on commit c2f7de2

Please sign in to comment.