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

pkgxdev / pkgx / 13778678716

11 Mar 2025 01:58AM UTC coverage: 90.952% (-0.09%) from 91.044%
13778678716

Pull #1144

github

web-flow
Merge abe78dfeb into c3a32e290
Pull Request #1144: --shift, -#

4 of 7 new or added lines in 2 files covered. (57.14%)

1 existing line in 1 file now uncovered.

1357 of 1492 relevant lines covered (90.95%)

18712457.82 hits per line

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

90.59
/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
    pub shebang: bool,
15
}
16

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

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

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

109
    Args {
30✔
110
        plus,
30✔
111
        args,
30✔
112
        find_program,
30✔
113
        mode,
30✔
114
        flags: Flags {
30✔
115
            shebang,
30✔
116
            silent,
30✔
117
            json,
30✔
118
            quiet,
30✔
119
            version_n_continue,
30✔
120
        },
30✔
121
    }
30✔
122
}
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