在提到StructOpt的“ Git”示例时,我不明白如何使用自变量中的数据。
我对Rust还是很陌生,所以我猜很明显。不幸的是,我可以用枚举找到的所有示例仅对println!对象执行一个操作,因此我被困住了。我以为我会做一个,match但没有用。
然后,您如何查找用户传递了哪些命令来运行程序?
#[macro_use]
extern crate structopt;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "git", about = "the stupid content tracker")]
enum Git {
#[structopt(name = "add")]
Add {
#[structopt(short = "i")]
interactive: bool,
#[structopt(short = "p")]
patch: bool,
#[structopt(parse(from_os_str))]
files: Vec<PathBuf>
},
#[structopt(name = "fetch")]
Fetch {
#[structopt(long = "dry-run")]
dry_run: bool,
#[structopt(long = "all")]
all: bool,
repository: Option<String>
},
#[structopt(name = "commit")]
Commit {
#[structopt(short = "m")]
message: …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Windows 上运行我的项目https://github.com/comit-network/create-comit-app/(主分支)(我通常在 unix 系统上编码)。
它恐慌但我无法获得回溯,尽管设置RUST_BACKTRACE=1或什至RUST_BACKTRACE=full.
我在同一台机器上编译和运行。
这是我得到的:
C:/Users/dante/.cargo/bin/cargo.exe run --color=always --package create-comit-app --bin create-comit-app --no-default-features -- start-env
Compiling create-comit-app v0.5.0 (C:\Users\dante\src\create-comit-app)
Finished dev [unoptimized + debuginfo] target(s) in 25.36s
Running `target\debug\create-comit-app.exe start-env`
Panic received, cleaning up...Panic received, cleaning up...thread panicked while processing panic. aborting.
error: process didn't exit successfully: `target\debug\create-comit-app.exe start-env` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)
Process finished with exit code -1073741795 (0xC000001D)
Run Code Online (Sandbox Code Playgroud)
经过一些研究,似乎应该可以在 Windows 上获得 BACKTRACE?
我在同一台机器上编码和运行:
Rust: 1.39.0
>rustc --version
rustc 1.39.0 …Run Code Online (Sandbox Code Playgroud)