mirror of
https://github.com/sigoden/aichat
synced 2024-11-18 09:28:27 +00:00
refactor: imports order and group
This commit is contained in:
parent
1ec451da89
commit
e78b5f7c58
@ -1,3 +1,9 @@
|
||||
use crate::utils::{emphasis, now};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use inquire::{Confirm, Text};
|
||||
use parking_lot::Mutex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
env,
|
||||
fs::{create_dir_all, read_to_string, File, OpenOptions},
|
||||
@ -7,14 +13,6 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use inquire::{Confirm, Text};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::utils::{emphasis, now};
|
||||
|
||||
const CONFIG_FILE_NAME: &str = "config.yaml";
|
||||
const ROLES_FILE_NAME: &str = "roles.yaml";
|
||||
const HISTORY_FILE_NAME: &str = "history.txt";
|
||||
|
19
src/main.rs
19
src/main.rs
@ -7,21 +7,20 @@ mod term;
|
||||
#[macro_use]
|
||||
mod utils;
|
||||
|
||||
use std::io::{stdin, Read};
|
||||
use std::sync::Arc;
|
||||
use std::{io::stdout, process::exit};
|
||||
|
||||
use cli::Cli;
|
||||
use client::ChatGptClient;
|
||||
use config::{Config, SharedConfig};
|
||||
use crossbeam::sync::WaitGroup;
|
||||
use is_terminal::IsTerminal;
|
||||
use parking_lot::Mutex;
|
||||
use crate::cli::Cli;
|
||||
use crate::client::ChatGptClient;
|
||||
use crate::config::{Config, SharedConfig};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use clap::Parser;
|
||||
use crossbeam::sync::WaitGroup;
|
||||
use is_terminal::IsTerminal;
|
||||
use parking_lot::Mutex;
|
||||
use render::{render_stream, MarkdownRender};
|
||||
use repl::{AbortSignal, Repl};
|
||||
use std::io::{stdin, Read};
|
||||
use std::sync::Arc;
|
||||
use std::{io::stdout, process::exit};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::MarkdownRender;
|
||||
|
||||
use crate::print_now;
|
||||
use crate::repl::{ReplyStreamEvent, SharedAbortSignal};
|
||||
|
||||
|
@ -9,6 +9,7 @@ use self::repl::repl_render_stream;
|
||||
use crate::client::ChatGptClient;
|
||||
use crate::print_now;
|
||||
use crate::repl::{ReplyStreamHandler, SharedAbortSignal};
|
||||
|
||||
use anyhow::Result;
|
||||
use crossbeam::channel::unbounded;
|
||||
use crossbeam::sync::WaitGroup;
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::MarkdownRender;
|
||||
|
||||
use crate::repl::{ReplyStreamEvent, SharedAbortSignal};
|
||||
|
||||
use anyhow::Result;
|
||||
|
@ -3,13 +3,13 @@ use crate::config::SharedConfig;
|
||||
use crate::print_now;
|
||||
use crate::render::render_stream;
|
||||
|
||||
use super::abort::SharedAbortSignal;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use crossbeam::channel::Sender;
|
||||
use crossbeam::sync::WaitGroup;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use super::abort::SharedAbortSignal;
|
||||
|
||||
pub enum ReplCmd {
|
||||
Submit(String),
|
||||
SetRole(String),
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::Repl;
|
||||
use super::REPL_COMMANDS;
|
||||
|
||||
use crate::config::{Config, SharedConfig};
|
||||
|
||||
@ -9,8 +10,6 @@ use reedline::{
|
||||
ReedlineMenu, ValidationResult, Validator,
|
||||
};
|
||||
|
||||
use super::REPL_COMMANDS;
|
||||
|
||||
const MENU_NAME: &str = "completion_menu";
|
||||
|
||||
impl Repl {
|
||||
|
@ -2,6 +2,9 @@ mod abort;
|
||||
mod handler;
|
||||
mod init;
|
||||
|
||||
pub use self::abort::*;
|
||||
pub use self::handler::*;
|
||||
|
||||
use crate::client::ChatGptClient;
|
||||
use crate::config::SharedConfig;
|
||||
use crate::print_now;
|
||||
@ -11,9 +14,6 @@ use anyhow::{Context, Result};
|
||||
use reedline::{DefaultPrompt, Reedline, Signal};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use self::abort::*;
|
||||
pub use self::handler::*;
|
||||
|
||||
pub const REPL_COMMANDS: [(&str, &str, bool); 10] = [
|
||||
(".info", "Print the information", false),
|
||||
(".set", "Modify the configuration temporarily", false),
|
||||
|
@ -1,11 +1,9 @@
|
||||
use std::io::{self, Stdout, Write};
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crossterm::{
|
||||
cursor, queue, style,
|
||||
terminal::{self, disable_raw_mode, enable_raw_mode, ClearType},
|
||||
};
|
||||
use std::io::{self, Stdout, Write};
|
||||
|
||||
pub fn clear_screen(keep_lines: u16) -> Result<()> {
|
||||
enable_raw_mode()?;
|
||||
|
Loading…
Reference in New Issue
Block a user