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

pkgxdev / pkgx / 12776318553

14 Jan 2025 09:02PM UTC coverage: 1.643% (-87.9%) from 89.526%
12776318553

push

github

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

13 of 791 relevant lines covered (1.64%)

0.28 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 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 {
×
23
    let mut mode = Mode::X;
×
24
    let mut plus = Vec::new();
×
25
    let mut args = Vec::new();
×
26
    let mut silent: bool = false;
×
27
    let mut json: bool = false;
×
28
    let mut find_program = false;
×
29
    let mut collecting_args = false;
×
30

31
    for arg in std::env::args().skip(1) {
×
32
        if collecting_args {
×
33
            args.push(arg);
×
34
        } else if arg.starts_with('+') {
×
35
            plus.push(arg.trim_start_matches('+').to_string());
×
36
        } else if arg == "--" {
×
37
            find_program = false;
×
38
            collecting_args = true;
×
39
        } else if arg.starts_with("--") {
×
40
            match arg.as_str() {
×
41
                "--json" => {
×
42
                    if !silent {
×
43
                        eprintln!(
×
44
                            "{} use --json=v1",
45
                            style("warning: --json is not stable").yellow()
46
                        );
47
                    }
48
                    json = true
×
49
                }
50
                "--json=v1" => json = true,
×
51
                "--silent" => silent = true,
×
52
                "--help" => mode = Mode::Help,
×
53
                "--version" => mode = Mode::Version,
×
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 {
92
        plus,
93
        args,
94
        find_program,
95
        mode,
96
        flags: Flags { silent, json },
×
97
    }
98
}
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