MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / main

Function main

atomic-cli/src/main.rs:909–1045  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

907}
908
909fn main() {
910 // Initialize logging
911 init_logging();
912
913 // Dynamic shell completion. When invoked in completion mode (the `COMPLETE`
914 // env var is set by the installed shell hook), this emits candidates —
915 // including live view names and change hashes registered on the insert
916 // args — and exits before normal argument parsing. In normal invocations
917 // it is a no-op. The factory mirrors the real command tree so completion
918 // matches actual subcommands and aliases.
919 clap_complete::CompleteEnv::with_factory(|| apply_agent_help(Cli::command())).complete();
920
921 // Parse command-line arguments through the agent-native help layout.
922 //
923 // `try_get_matches_from_mut` rather than `get_matches`: clap's own failure
924 // output is human prose ending in "For more information, try '--help'",
925 // which costs an agent a second round trip and may discard the option/value
926 // relationship or the parser's underlying cause. We intercept and re-render
927 // in the same `key: value` dialect the rest of the machine surface speaks.
928 // Help and version still print through clap untouched.
929 let mut cmd = apply_agent_help(Cli::command());
930 let args: Vec<std::ffi::OsString> = std::env::args_os().collect();
931 let matches = match cmd.try_get_matches_from_mut(args.clone()) {
932 Ok(matches) => matches,
933 Err(err) => agent_error::render_and_exit(err, &cmd, &args),
934 };
935 let cli = match Cli::from_arg_matches(&matches) {
936 Ok(cli) => cli,
937 Err(err) => agent_error::render_and_exit(err, &cmd, &args),
938 };
939
940 // Configure color output
941 if cli.no_color {
942 // Disable colors globally
943 console::set_colors_enabled(false);
944 console::set_colors_enabled_stderr(false);
945 }
946
947 // Execute the command and handle errors
948 let result = match cli.command {
949 Commands::Agent(agent) => agent.run(),
950
951 Commands::Init(init) => init.run(),
952
953 Commands::Status(status) => status.run(),
954
955 Commands::Add(add) => add.run(),
956
957 Commands::Remove(remove) => remove.run(),
958
959 Commands::Move(mv) => mv.run(),
960
961 Commands::Restore(restore) => restore.run(),
962
963 Commands::Sandbox(sandbox) => sandbox.run(),
964
965 Commands::Session(session) => session.run(),
966

Callers

nothing calls this directly

Calls 10

init_loggingFunction · 0.85
apply_agent_helpFunction · 0.85
commandFunction · 0.85
render_and_exitFunction · 0.85
print_errorFunction · 0.85
cloneMethod · 0.45
runMethod · 0.45
generateMethod · 0.45
suggestionMethod · 0.45
exit_codeMethod · 0.45

Tested by

no test coverage detected