MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / main

Function main

aiscript/src/main.rs:49–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48#[tokio::main]
49async fn main() {
50 dotenv::dotenv().ok();
51 Config::load("project.toml");
52
53 let cli = AIScriptCli::parse();
54 match cli.command {
55 Some(Commands::Serve { file, port, reload }) => {
56 println!("Server listening on port http://localhost:{}", port);
57 aiscript_runtime::run(file, port, reload).await;
58 }
59 Some(Commands::New { name }) => {
60 let generator = ProjectGenerator::new(&name);
61 if let Err(e) = generator.generate() {
62 eprintln!("{}", e);
63 process::exit(1);
64 }
65 }
66 None => {
67 if let Some(path) = cli.file {
68 let pg_connection = aiscript_runtime::get_pg_connection().await;
69 let sqlite_connection = aiscript_runtime::get_sqlite_connection().await;
70 let redis_connection = aiscript_runtime::get_redis_connection().await;
71 task::spawn_blocking(move || {
72 let mut vm = Vm::new(pg_connection, sqlite_connection, redis_connection);
73 vm.run_file(path);
74 })
75 .await // must use await to wait for the thread to finish
76 .unwrap();
77 } else {
78 // Run the repl
79 let mut repl = Repl::new();
80 if let Err(e) = repl.run() {
81 eprintln!("Error: {}", e);
82 process::exit(1);
83 }
84 }
85 }
86 }
87}

Callers

nothing calls this directly

Calls 7

runFunction · 0.85
get_pg_connectionFunction · 0.85
get_sqlite_connectionFunction · 0.85
get_redis_connectionFunction · 0.85
run_fileMethod · 0.80
runMethod · 0.80
generateMethod · 0.45

Tested by

no test coverage detected