MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / main

Function main

gql-cli/src/main.rs:12–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10use cli::{Cli, Commands};
11
12fn 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}

Callers

nothing calls this directly

Calls 5

handle_installFunction · 0.85
handle_gqlFunction · 0.85
handle_queryFunction · 0.85
to_level_filterMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected