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

pkgxdev / pkgx / 13632692143

03 Mar 2025 02:03PM UTC coverage: 90.32% (+1.2%) from 89.102%
13632692143

push

github

mxcl
Build on windows

13 of 16 new or added lines in 4 files covered. (81.25%)

52 existing lines in 5 files now uncovered.

1325 of 1467 relevant lines covered (90.32%)

19031327.83 hits per line

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

91.36
/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 {
32✔
25
    let mut mode = Mode::X;
32✔
26
    let mut plus = Vec::new();
32✔
27
    let mut args = Vec::new();
32✔
28
    let mut silent: bool = false;
32✔
29
    let mut quiet: bool = false;
32✔
30
    let mut json: bool = false;
32✔
31
    let mut find_program = false;
32✔
32
    let mut collecting_args = false;
32✔
33
    let mut version_n_continue = false;
32✔
34

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

105
    Args {
30✔
106
        plus,
30✔
107
        args,
30✔
108
        find_program,
30✔
109
        mode,
30✔
110
        flags: Flags {
30✔
111
            silent,
30✔
112
            json,
30✔
113
            quiet,
30✔
114
            version_n_continue,
30✔
115
        },
30✔
116
    }
30✔
117
}
30✔
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