• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pkgxdev / pkgx / 13080646583

31 Jan 2025 08:56PM UTC coverage: 1.58% (-89.3%) from 90.909%
13080646583

push

github

mxcl
Update `Cargo.lock`

13 of 823 relevant lines covered (1.58%)

0.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/crates/cli/src/args.rs
1
use console::style;
2

3
pub enum Mode {
4
    X,
5
    Help,
6
    Version,
7
}
8

9
pub struct Flags {
10
    pub quiet: bool,
11
    pub silent: bool,
12
    pub json: bool,
13
    pub version_n_continue: bool,
14
}
15

16
pub struct Args {
17
    pub plus: Vec<String>,
18
    pub args: Vec<String>,
19
    pub find_program: bool,
20
    pub mode: Mode,
21
    pub flags: Flags,
22
}
23

24
pub fn parse() -> Args {
×
25
    let mut mode = Mode::X;
×
26
    let mut plus = Vec::new();
×
27
    let mut args = Vec::new();
×
28
    let mut silent: bool = false;
×
29
    let mut quiet: bool = false;
×
30
    let mut json: bool = false;
×
31
    let mut find_program = false;
×
32
    let mut collecting_args = false;
×
33
    let mut version_n_continue = false;
×
34

35
    for arg in std::env::args().skip(1) {
×
36
        if collecting_args {
×
37
            args.push(arg);
×
38
        } else if arg.starts_with('+') {
×
39
            plus.push(arg.trim_start_matches('+').to_string());
×
40
        } else if arg == "--" {
×
41
            find_program = false;
×
42
            collecting_args = true;
×
43
        } else if arg.starts_with("--") {
×
44
            match arg.as_str() {
×
45
                "--json" => {
×
46
                    if !silent {
×
47
                        eprintln!(
×
48
                            "{} use --json=v1",
49
                            style("warning: --json is not stable").yellow()
50
                        );
51
                    }
52
                    json = true
×
53
                }
54
                "--json=v1" => json = true,
×
55
                "--silent" => silent = true,
×
56
                "--help" => mode = Mode::Help,
×
57
                "--version" => mode = Mode::Version,
×
58
                "--quiet" => quiet = true,
×
59
                "--shellcode" => {
×
60
                    if !silent {
×
61
                        eprintln!("{}", style("⨯ migration required").red());
×
62
                        eprintln!(
×
63
                            "{} pkgx^2 is now exclusively focused on executing packages",
64
                            style("│").red()
65
                        );
66
                        eprintln!(
×
67
                            "{} you need to migrate to the new, isolated `dev` command",
68
                            style("│").red()
69
                        );
70
                        eprintln!("{} run the following:", style("│").red());
×
71
                        eprintln!(
×
72
                            "{} pkgx pkgx^1 deintegrate && pkgx dev integrate",
73
                            style("╰─➤").red()
74
                        );
75
                    }
76
                    std::process::exit(1);
×
77
                }
78
                _ => panic!("unknown argument {}", arg),
×
79
            }
80
        } else if arg.starts_with('-') {
×
81
            // spit arg into characters
82
            for c in arg.chars().skip(1) {
×
83
                match c {
×
84
                    'q' => {
85
                        if quiet {
×
86
                            silent = true
×
87
                        } else {
88
                            quiet = true
×
89
                        }
90
                    }
91
                    'h' => mode = Mode::Help,
×
92
                    's' => silent = true,
×
93
                    'j' => json = true,
×
94
                    'v' => version_n_continue = true,
×
95
                    _ => panic!("unknown argument: -{}", c),
×
96
                }
97
            }
98
        } else {
99
            find_program = !arg.contains('/');
×
100
            collecting_args = true;
×
101
            args.push(arg);
×
102
        }
103
    }
104

105
    Args {
106
        plus,
107
        args,
108
        find_program,
109
        mode,
110
        flags: Flags {
×
111
            silent,
112
            json,
113
            quiet,
114
            version_n_continue,
115
        },
116
    }
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc