1pub mod auth;
2pub mod cache;
3pub mod challenges;
4pub mod ctf;
5pub mod machines;
6pub mod pwnbox;
7pub mod search;
8pub mod seasons;
9pub mod sherlocks;
10pub mod user;
11pub mod vpn;
12
13use std::path::PathBuf;
14
15use clap::{Parser, Subcommand};
16
17#[derive(Parser)]
18#[command(
19 name = "htb",
20 version,
21 about = "Hack The Box CLI",
22 long_about = "Hack The Box CLI - interact with the HTB platform from your terminal.\n\nQuery machines, challenges, Sherlocks, and seasons. Spawn instances, submit flags, manage VPN connections.",
23 after_help = "Examples:\n htb auth login Save your API token\n htb machines list --os linux --difficulty easy Filter machines\n htb machines start Bedside Spawn a machine\n htb challenges list --category Web Browse web challenges\n htb challenges submit 1018 'HTB{flag}' Submit a challenge flag\n htb vpn list Show VPN servers\n htb user me View your profile\n htb search nmap Search across all content"
24)]
25pub struct Cli {
26 #[command(subcommand)]
27 pub command: Command,
28
29 #[arg(long, global = true, help = "Output as JSON")]
30 pub json: bool,
31
32 #[arg(long, global = true, help = "Disable colored output")]
33 pub no_color: bool,
34
35 #[arg(short, long, global = true, help = "Enable debug logging")]
36 pub verbose: bool,
37
38 #[arg(long, global = true, help = "Override config file path")]
39 pub config: Option<PathBuf>,
40
41 #[arg(long, global = true, help = "Bypass response cache")]
42 pub no_cache: bool,
43}
44
45#[derive(Subcommand)]
46pub enum Command {
47 Auth {
49 #[command(subcommand)]
50 command: auth::AuthCommand,
51 },
52 Machines {
54 #[command(subcommand)]
55 command: machines::MachineCommand,
56 },
57 Challenges {
59 #[command(subcommand)]
60 command: challenges::ChallengeCommand,
61 },
62 Seasons {
64 #[command(subcommand)]
65 command: seasons::SeasonCommand,
66 },
67 Sherlocks {
69 #[command(subcommand)]
70 command: sherlocks::SherlockCommand,
71 },
72 Vpn {
74 #[command(subcommand)]
75 command: vpn::VpnCommand,
76 },
77 User {
79 #[command(subcommand)]
80 command: user::UserCommand,
81 },
82 Pwnbox {
84 #[command(subcommand)]
85 command: pwnbox::PwnboxCommand,
86 },
87 Ctf {
89 #[command(subcommand)]
90 command: ctf::CtfCommand,
91 },
92 Search {
94 query: String,
96 },
97 Cache {
99 #[command(subcommand)]
100 command: cache::CacheCommand,
101 },
102}