MCPcopy Create free account
hub / github.com/Roy3838/Observer / main

Function main

cli/src/main.rs:58–253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56
57#[tokio::main]
58async fn main() {
59 let cli = Cli::parse();
60
61 // Handle subcommands
62 if let Some(cmd) = cli.command {
63 match cmd {
64 Commands::Login => {
65 if let Err(e) = auth::login().await {
66 eprintln!("Login failed: {}", e);
67 std::process::exit(1);
68 }
69 return;
70 }
71 Commands::Logout => {
72 if let Err(e) = auth::logout() {
73 eprintln!("Logout failed: {}", e);
74 std::process::exit(1);
75 }
76 return;
77 }
78 Commands::Whoami => {
79 auth::whoami();
80 return;
81 }
82 }
83 }
84
85 // No subcommand - run a command and notify
86 if cli.args.is_empty() {
87 eprintln!("Usage: observe [OPTIONS] <COMMAND>...");
88 eprintln!(" observe login");
89 eprintln!(" observe logout");
90 eprintln!(" observe whoami");
91 eprintln!();
92 eprintln!("Options:");
93 eprintln!(" --discord Configure Discord webhook");
94 eprintln!(" --telegram Configure Telegram (requires login)");
95 eprintln!(" --sms Configure SMS (requires login)");
96 eprintln!(" --whatsapp Configure WhatsApp (requires login)");
97 eprintln!(" --call Configure voice call (requires login)");
98 eprintln!(" --email Configure email (requires login)");
99 eprintln!();
100 eprintln!("On first run, you'll be prompted to select a notification method.");
101 eprintln!("Use --<method> flags to reconfigure a specific method.");
102 eprintln!();
103 eprintln!("Run 'observe --help' for more information.");
104 std::process::exit(1);
105 }
106
107 // Load config
108 let mut config = Config::load();
109
110 // Determine notification channel and whether to reconfigure
111 let (channel, reconfigure) = if cli.discord {
112 (NotifyChannel::Discord, true)
113 } else if cli.telegram {
114 (NotifyChannel::Telegram, true)
115 } else if cli.sms {

Callers

nothing calls this directly

Calls 15

loginFunction · 0.85
logoutFunction · 0.85
whoamiFunction · 0.85
wait_for_whitelistFunction · 0.85
run_commandFunction · 0.85
send_sms_notificationFunction · 0.85
send_call_notificationFunction · 0.85
send_email_notificationFunction · 0.85
is_first_runMethod · 0.80

Tested by

no test coverage detected