1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Command line entry point.
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
use std::process;
use clap::{Parser, Subcommand};
mod breakpoint;
mod debug_utils;
mod listen;
mod protocol;
mod sigint;
mod test_utils;
mod util;
#[derive(Debug, Parser)]
#[command(name = "breakmancer")]
#[command(about = "Drop a breakpoint into any shell.")]
#[command(version, arg_required_else_help = true)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand, Debug)]
enum Commands {
/// Start a new session.
///
/// When `listen` is called, it will give you a command to run on
/// the breakpoint host. The breakpoint end will try to open a connection
/// to the callback address, at which point a secure handshake
/// will occur and a debugging session can start.
#[command()]
Listen(listen::Cli),
/// Break for debugging.
///
/// Call back to a `listen` session so that the developer can run
/// commands in this environment. This command and its parameters
/// will be provided by the output of the `listen` command.
#[command()]
Break(breakpoint::Cli),
}
#[tokio::main]
async fn main() {
let args = Cli::parse();
let outcome = match args.command {
Commands::Listen(args) => listen::run(&args).await,
Commands::Break(args) => breakpoint::run(&args).await,
};
if let Err(err) = outcome {
eprintln!("{err}");
process::exit(1)
}
}