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

Function main

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

Source from the content-addressed store, hash-verified

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

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