1#![allow(dead_code)]
9
10pub mod command_parser;
11pub mod commands;
12pub mod completion;
13pub mod engine;
14pub mod history;
15pub mod session;
16
17pub use command_parser::{CommandParser, CommandType, ParsedCommand, SchemaOperation};
19pub use completion::CompletionEngine;
20pub use engine::{ReplConfig, ReplEngine};
21pub use history::HistoryManager;
22pub use session::{ReplSession, SessionState};
23
24pub type ReplResult<T> = Result<T, ReplError>;
26
27#[derive(Debug, thiserror::Error)]
29pub enum ReplError {
30 #[error("IO error: {0}")]
31 Io(#[from] std::io::Error),
32
33 #[error("Database error: {0}")]
34 Database(#[from] anyhow::Error),
35
36 #[error("Command parsing error: {0}")]
37 CommandParsing(String),
38
39 #[error("Invalid configuration: {0}")]
40 Config(String),
41
42 #[error("Session error: {0}")]
43 Session(String),
44
45 #[error("History error: {0}")]
46 History(String),
47
48 #[error("Completion error: {0}")]
49 Completion(String),
50
51 #[error("Schema error: {0}")]
53 SchemaError(String),
54
55 #[error("Data directory error: {0}")]
57 DataDirectoryError(String),
58
59 #[error("Unsupported feature: {0}")]
61 UnsupportedFeature(String),
62}
63
64impl ReplError {
65 pub fn exit_code(&self) -> i32 {
67 match self {
68 ReplError::SchemaError(_) => 3,
69 ReplError::DataDirectoryError(_) => 4,
70 ReplError::UnsupportedFeature(_) => 5,
71 _ => 1, }
73 }
74}
75
76#[derive(Debug, Clone, PartialEq)]
78pub enum ExecutionResult {
79 Continue,
81 Exit,
83 ExitWithCode(i32),
85}
86
87#[derive(Debug, Clone, PartialEq)]
89pub enum ReplMode {
90 Basic,
92 Tui,
94 Interactive,
96}
97
98#[derive(Debug, Clone, PartialEq)]
100pub enum OutputFormat {
101 Table,
103 Csv,
105 Json,
107 Raw,
109}
110
111#[derive(Debug, Clone)]
113pub struct CompletionContext {
114 pub line: String,
116 pub pos: usize,
118 pub session_state: SessionState,
120 pub tables: Vec<String>,
122 pub keyspaces: Vec<String>,
124}