()
| 10 | use cli::{Cli, Commands}; |
| 11 | |
| 12 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 13 | // Parse command line arguments first to get log level |
| 14 | let cli = Cli::parse(); |
| 15 | |
| 16 | // Determine log level from CLI args or environment variable |
| 17 | let log_level = if cli.verbose { |
| 18 | // -v/--verbose flag takes precedence |
| 19 | log::LevelFilter::Debug |
| 20 | } else if let Some(level) = cli.log_level { |
| 21 | // --log-level flag |
| 22 | level.to_level_filter() |
| 23 | } else { |
| 24 | // Default to Warn (can still be overridden by RUST_LOG env var) |
| 25 | log::LevelFilter::Warn |
| 26 | }; |
| 27 | |
| 28 | // Initialize logger |
| 29 | env_logger::Builder::from_default_env() |
| 30 | .filter_level(log_level) |
| 31 | .init(); |
| 32 | |
| 33 | // Handle commands |
| 34 | match cli.command { |
| 35 | Commands::Version => { |
| 36 | println!("{} {}", "GraphLite".bold().green(), graphlite::VERSION); |
| 37 | println!("ISO GQL Graph Database"); |
| 38 | Ok(()) |
| 39 | } |
| 40 | |
| 41 | Commands::Install { |
| 42 | path, |
| 43 | admin_user, |
| 44 | admin_password, |
| 45 | force, |
| 46 | yes, |
| 47 | } => cli::handle_install(path, admin_user, admin_password, force, yes), |
| 48 | |
| 49 | Commands::Gql { path, sample } => cli::handle_gql(path, cli.user, cli.password, sample), |
| 50 | |
| 51 | Commands::Query { |
| 52 | query, |
| 53 | path, |
| 54 | format, |
| 55 | explain, |
| 56 | ast, |
| 57 | } => cli::handle_query(path, query, cli.user, cli.password, format, explain, ast), |
| 58 | |
| 59 | Commands::Session { action: _, path: _ } => { |
| 60 | println!("{}", "Session management not yet implemented".yellow()); |
| 61 | Ok(()) |
| 62 | } |
| 63 | } |
| 64 | } |
nothing calls this directly
no test coverage detected