MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / main

Function main

crates/cli/src/main.rs:26–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24#[cfg(not(feature = "markdown-docs"))]
25#[tokio::main]
26async fn main() -> anyhow::Result<ExitCode> {
27 use spacetimedb_paths::SpacetimePaths;
28
29 // Compute matches before loading the config, because `Config` has an observable `drop` method
30 // (which deletes a lockfile),
31 // and Clap calls `exit` on parse failure rather than panicking, so destructors never run.
32 let matches = get_command().get_matches();
33 let (cmd, subcommand_args) = matches.subcommand().unwrap();
34
35 let root_dir = matches.get_one::<RootDir>("root_dir");
36 let paths = match root_dir {
37 Some(dir) => SpacetimePaths::from_root_dir(dir),
38 None => SpacetimePaths::platform_defaults()?,
39 };
40 let cli_toml = matches
41 .get_one::<CliTomlPath>("config_path")
42 .cloned()
43 .unwrap_or_else(|| paths.cli_config_dir.cli_toml());
44 let config = Config::load(cli_toml)?;
45
46 exec_subcommand(config, &paths, root_dir, cmd, subcommand_args)
47 .await
48 .or_else(|e| e.downcast::<ExitWithCode>().map(|e| e.0))
49}
50
51#[cfg(feature = "markdown-docs")]
52#[tokio::main]

Callers

nothing calls this directly

Calls 6

cli_tomlMethod · 0.80
get_commandFunction · 0.70
exec_subcommandFunction · 0.70
OkFunction · 0.50
unwrapMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…