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

Function main

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

Source from the content-addressed store, hash-verified

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

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