-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathmain.rs
More file actions
69 lines (65 loc) · 2.28 KB
/
main.rs
File metadata and controls
69 lines (65 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// This is a standalone test utility binary that deliberately uses std types
// rather than the project's custom types (vite_str, vite_path, etc.).
#![expect(clippy::disallowed_types, reason = "standalone test utility uses std types")]
#![expect(clippy::disallowed_macros, reason = "standalone test utility uses std macros")]
#![expect(clippy::disallowed_methods, reason = "standalone test utility uses std methods")]
#![expect(clippy::print_stderr, reason = "CLI tool error output")]
#![expect(clippy::print_stdout, reason = "CLI tool output")]
mod barrier;
mod check_tty;
mod cp;
mod exit;
mod exit_on_ctrlc;
mod mkdir;
mod pipe_stdin;
mod print;
mod print_cwd;
mod print_env;
mod print_file;
mod read_stdin;
mod replace_file_content;
mod rm;
mod touch_file;
mod write_file;
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
eprintln!("Usage: vtt <subcommand> [args...]");
eprintln!(
"Subcommands: barrier, check-tty, cp, exit, exit-on-ctrlc, mkdir, pipe-stdin, print, print-cwd, print-env, print-file, read-stdin, replace-file-content, rm, touch-file, write-file"
);
std::process::exit(1);
}
let result: Result<(), Box<dyn std::error::Error>> = match args[1].as_str() {
"barrier" => barrier::run(&args[2..]),
"check-tty" => {
check_tty::run();
Ok(())
}
"cp" => cp::run(&args[2..]),
"exit" => exit::run(&args[2..]),
"exit-on-ctrlc" => exit_on_ctrlc::run(),
"mkdir" => mkdir::run(&args[2..]),
"pipe-stdin" => pipe_stdin::run(&args[2..]),
"print" => {
print::run(&args[2..]);
Ok(())
}
"print-cwd" => print_cwd::run(),
"print-env" => print_env::run(&args[2..]),
"print-file" => print_file::run(&args[2..]),
"read-stdin" => read_stdin::run(),
"replace-file-content" => replace_file_content::run(&args[2..]),
"rm" => rm::run(&args[2..]),
"touch-file" => touch_file::run(&args[2..]),
"write-file" => write_file::run(&args[2..]),
other => {
eprintln!("Unknown subcommand: {other}");
std::process::exit(1);
}
};
if let Err(err) = result {
eprintln!("{err}");
std::process::exit(1);
}
}