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

pkgxdev / pkgx / 12769171188

14 Jan 2025 01:57PM UTC coverage: 1.487% (-90.4%) from 91.907%
12769171188

push

github

web-flow
Merge pull request #1068 from pkgxdev/v2

v2

13 of 874 new or added lines in 17 files covered. (1.49%)

13 of 874 relevant lines covered (1.49%)

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

88
    Args {
89
        plus,
90
        args,
91
        find_program,
92
        mode,
NEW
93
        flags: Flags { silent, json },
×
94
    }
95
}
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