-
Notifications
You must be signed in to change notification settings - Fork 83
Defaults fail to load #182
Comments
Could you please provide source code that I can compile and run? I can't reproduce your problem. My extern crate docopt;
extern crate rustc_serialize;
use docopt::Docopt;
const USAGE: &'static str = "
Usage:
prog <folder> [--output=FILE]
prog (--help | --version)
Options:
--help # Display this help message.
--version # Displays the program version.
--output=<file> # Specifies a output name [default: game.grav].
";
#[derive(Debug, RustcDecodable)]
struct Args {
arg_folder: Option<String>,
flag_output: String,
flag_help: bool,
flag_version: bool,
}
fn main() {
let args: Args = Docopt::new(USAGE).and_then(|d| d.decode())
.unwrap_or_else(|e| e.exit());
println!("{:?}", args);
} My [package]
name = "docopt-182"
version = "0.1.0"
authors = ["Andrew Gallant <[email protected]>"]
[dependencies]
docopt = "0.6"
rustc-serialize = "0.3" And running it:
Which shows that |
My main.rs: extern crate tar;
extern crate bzip2;
extern crate base64;
extern crate docopt;
extern crate rustc_serialize;
const USAGE: &'static str = "
Validates and packages a Gravity project folder.
Usage:
gravity-packer <folder> [--output=FILE]
gravity-packer (--help | --version)
Options:
--help # Display this help message.
--version # Displays the program version.
--output=FILE # Specifies a output name [default: game.grav].
";
#[derive(Debug, RustcDecodable)]
struct Args {
arg_folder: Option<String>,
flag_output: String,
flag_help: bool,
flag_version: bool
}
use docopt::Docopt;
fn main() {
let args: Args = Docopt::new(USAGE)
.and_then(|d| d.decode())
.unwrap_or_else(|e| e.exit());
println!("{:?}", args);
if args.arg_folder.is_some() {
// Read folder w/ output
println!("Output to {}?", args.flag_output);
} else if args.flag_help {
println!("{}", USAGE)
} else if args.flag_version {
println!("Version {}", option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"))
}
} My Cargo.toml: [package]
name = "gravity-packer"
version = "0.1.0"
authors = ["Bobhostern <[email protected]>"]
[dependencies]
base64 = "0.1"
bzip2 = "0.3"
tar = "0.4"
docopt = "0.6"
rustc-serialize = "0.3"
walkdir = "0.1" When I run the program with
Using windows cmd.exe, and even your example produces no flag_output. 😖 I dunno what's going on. |
@Bobhostern Can you show your |
Cargo.lock: [root]
name = "gravity-packer"
version = "0.1.0"
dependencies = [
"base64 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bzip2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "aho-corasick"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "base64"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bzip2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bzip2-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bzip2-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "docopt"
version = "0.6.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"regex 0.1.68 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "filetime"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gcc"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "memchr"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
version = "0.1.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-serialize"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "strsim"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "tar"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "thread-id"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "thread_local"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "utf8-ranges"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "walkdir"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
|
I'm unfortunately not sure. If you're still getting the problem even with my code, then maybe there is a Windows bug lurking somewhere? I'll investigate eventually, but it might be a bit. Sorry. :-( |
FWIW, I can also seem to replicate this with the following (taken from @BurntSushi's example): extern crate docopt;
use docopt::Docopt;
const USAGE: &'static str = "
Usage:
prog <folder> [--output=FILE]
prog (--help | --version)
Options:
--help # Display this help message.
--version # Displays the program version.
--output=<file> # Specifies a output name [default: game.grav].
";
fn main() {
let args = Docopt::new(USAGE).and_then(|d| d.parse())
.unwrap_or_else(|e| e.exit());
println!("{:?}", args);
} |
Can corroborate that defaults are not loading for an ARMv6 Raspbian build. |
I have this usage string here, nearly verbatim:
Whenever I run it using this struct:
and I use the command line:
*******-packer game
, it gives me""
forflag_output
, even though I specified a default. Is there anything I'm doing wrong?The text was updated successfully, but these errors were encountered: