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

pkgxdev / pkgx / 12771503551

14 Jan 2025 03:58PM UTC coverage: 1.643% (-90.3%) from 91.907%
12771503551

push

github

mxcl
ts → rs

13 of 791 new or added lines in 17 files covered. (1.64%)

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

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

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

91
    Args {
92
        plus,
93
        args,
94
        find_program,
95
        mode,
NEW
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