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

pkgxdev / pkgx / 12776146238

14 Jan 2025 08:49PM UTC coverage: 87.979% (-1.5%) from 89.526%
12776146238

push

github

mxcl
get coverage from running `pkgx` (#1072)

1171 of 1331 relevant lines covered (87.98%)

186.65 hits per line

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

56.45
/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 silent: bool,
11
    pub json: bool,
12
}
13

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

22
pub fn parse() -> Args {
4✔
23
    let mut mode = Mode::X;
4✔
24
    let mut plus = Vec::new();
4✔
25
    let mut args = Vec::new();
4✔
26
    let mut silent: bool = false;
4✔
27
    let mut json: bool = false;
4✔
28
    let mut find_program = false;
4✔
29
    let mut collecting_args = false;
4✔
30

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

91
    Args {
4✔
92
        plus,
4✔
93
        args,
4✔
94
        find_program,
4✔
95
        mode,
4✔
96
        flags: Flags { silent, json },
4✔
97
    }
4✔
98
}
4✔
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