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
pub mod auth;
pub mod issue;
pub mod label;
pub mod milestone;
pub mod notification;
pub mod pull_request;
pub mod repo;
pub mod user;

use clap::{CommandFactory, Parser};
use clap_complete::Shell;

pub const LOGO: &str = include_str!("logo.txt");

pub fn generate_completion(shell: Shell, bin_name: &str) {
    let cmd = &mut MainArgs::command();
    clap_complete::generate(shell, cmd, bin_name, &mut std::io::stdout());
}

/// Codeberg CLI app
#[derive(Parser, Debug)]
#[command(name = "berg", version, before_long_help = LOGO)]
pub enum MainArgs {
    #[command(subcommand)]
    Auth(auth::AuthArgs),

    #[command(subcommand)]
    User(user::UserArgs),

    #[command(subcommand)]
    Issue(issue::IssueArgs),

    #[command(subcommand)]
    Pull(pull_request::PullRequestArgs),

    #[command(subcommand)]
    Label(label::LabelArgs),

    #[command(subcommand)]
    Repo(repo::RepoArgs),

    #[command(subcommand)]
    Milestone(milestone::MilestoneArgs),

    #[command(subcommand)]
    Notification(notification::NotificationArgs),

    /// Print completion script
    Completion {
        /// Shell to generate completion for
        shell: Shell,
    },
}