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
60
61
62
63
64
65
66
67
68
69
70
71
|
use clap::Parser;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
mod create;
mod diff;
mod dump;
mod input;
mod validate;
/// Generate, inspect, and validate Binary Ninja type libraries (BNTL)
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Cli {
#[clap(subcommand)]
command: Command,
}
#[derive(Parser, Debug)]
pub enum Command {
/// Create a new type library from a set of files.
Create(create::CreateArgs),
/// Dump the type library to a C header file.
Dump(dump::DumpArgs),
/// Generate a diff between two type libraries.
Diff(diff::DiffArgs),
/// Validate the type libraries for common errors.
Validate(validate::ValidateArgs),
}
impl Command {
pub fn execute(&self) {
match self {
Command::Create(args) => {
args.execute();
}
Command::Dump(args) => {
args.execute();
}
Command::Diff(args) => {
args.execute();
}
Command::Validate(args) => {
args.execute();
}
}
}
}
fn main() {
let cli = Cli::parse();
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(
EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy(),
)
.init();
// Capture logs from Binary Ninja
let _listener = binaryninja::tracing::TracingLogListener::new().register();
// Initialize Binary Ninja, requires a headless compatible license like commercial or ultimate.
let _session = binaryninja::headless::Session::new()
.expect("Failed to create headless binary ninja session");
cli.command.execute();
}
|