{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/cargo/issues/2898","repository_url":"https://api.github.com/repos/rust-lang/cargo","labels_url":"https://api.github.com/repos/rust-lang/cargo/issues/2898/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/cargo/issues/2898/comments","events_url":"https://api.github.com/repos/rust-lang/cargo/issues/2898/events","html_url":"https://github.com/rust-lang/cargo/issues/2898","id":166638054,"number":2898,"title":"Cargo not passing arguments to executable","user":{"login":"Osspial","id":16296823,"avatar_url":"https://avatars.githubusercontent.com/u/16296823?v=3","gravatar_id":"","url":"https://api.github.com/users/Osspial","html_url":"https://github.com/Osspial","followers_url":"https://api.github.com/users/Osspial/followers","following_url":"https://api.github.com/users/Osspial/following{/other_user}","gists_url":"https://api.github.com/users/Osspial/gists{/gist_id}","starred_url":"https://api.github.com/users/Osspial/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Osspial/subscriptions","organizations_url":"https://api.github.com/users/Osspial/orgs","repos_url":"https://api.github.com/users/Osspial/repos","events_url":"https://api.github.com/users/Osspial/events{/privacy}","received_events_url":"https://api.github.com/users/Osspial/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-20T17:32:30Z","updated_at":"2016-07-21T16:05:02Z","closed_at":null,"body":"Currently, attempting to use `--` to pass arguments to the executable in cargo does not actually pass arguments to the executable, and in fact causes cargo to throw an error.\r\n\r\nLet's take the following program, in the cargo project `carg`, using the `clap` library version 2.9 for argument parsing:\r\n\r\n```rust\r\nextern crate clap;\r\nuse clap::{Arg, App};\r\n\r\nfn main() {\r\n    let matches = \r\n    \tApp::new(\"Cargo Argument-Passing Test\")\r\n    \t\t.arg(Arg::with_name(\"print\")\r\n    \t\t\t\t.short(\"p\")\r\n    \t\t\t\t.long(\"print\")\r\n    \t\t\t\t.takes_value(true))\r\n    \t\t.get_matches();\r\n\r\n    match matches.value_of(\"print\") {\r\n    \tSome(s) => println!(\"{}\", s),\r\n    \tNone    => println!(\"Error: No print value provided\")\r\n    }\r\n}\r\n```\r\n\r\nUsing this program is very simple - you simply tell it what to print with the argument `-p` or `--print` and it will print that string, unless the user does not provide a print argument, in which case it will print \"Error: No print value provided\". Navigating to the `/target/debug/` directory, we can test this ourselves:\r\n\r\n```\r\n> ./carg.exe -p rust\r\nrust\r\n\r\n> ./carg.exe --print github\r\ngithub\r\n\r\n> ./carg.exe\r\nError: No print value provided\r\n\r\n> ./carg.exe --foo\r\nerror: Found argument '--foo' which wasn't expected, or isn't valid in this context\r\n\r\nUSAGE:\r\n    carg.exe [OPTIONS]\r\n\r\n> \r\n```\r\n\r\nHowever, if we navigate back to the project's root folder and attempt sending the arguments through cargo, we get a cargo error. We would expect that cargo would pass the arguments to the executable, like so:\r\n\r\n```\r\n> cargo run -- --print foo\r\n     Running 'target\\debug\\carg.exe'\r\nfoo\r\n\r\n>\r\n```\r\n\r\nInstead, this happens (note that just running without arguments prints \"Error: No print value provided\" as expected): \r\n\r\n```\r\n> cargo run -- --print foo\r\nerror: Unknown flag: '--print'\r\n\r\nUsage:\r\n    cargo run [options] [--] [<args>...]\r\n\r\n> cargo run -- -p bar\r\nerror: Unknown flag: '-p'\r\n\r\nUsage:\r\n    cargo run [options] [--] [<args>...]\r\n\r\n> cargo run\r\n     Running 'target\\debug\\carg.exe'\r\nError: No print value provided\r\n\r\n>\r\n```\r\n\r\n# Meta\r\nThis issue occurs on both stable and nightly.\r\n\r\nStable versions: \r\n```\r\n> cargo --version\r\ncargo 0.11.0-nightly (259324c 2016-05-20)\r\n\r\n> rustc --version --verbose\r\nrustc 1.10.0 (cfcb716cf 2016-07-03)\r\nbinary: rustc\r\ncommit-hash: cfcb716cf0961a7e3a4eceac828d94805cf8140b\r\ncommit-date: 2016-07-03\r\nhost: x86_64-pc-windows-gnu\r\nrelease: 1.10.0\r\n```\r\n\r\nNightly versions:\r\n```\r\n> cargo --version\r\ncargo 0.13.0-nightly (15c1cd2 2016-07-17)\r\n\r\n> rustc --version --verbose\r\nrustc 1.12.0-nightly (34f35ed29 2016-07-17)\r\nbinary: rustc\r\ncommit-hash: 34f35ed29c8acdbe1e3c172786fc41d6f4fb6090\r\ncommit-date: 2016-07-17\r\nhost: x86_64-pc-windows-gnu\r\nrelease: 1.12.0-nightly\r\n```"},"comment":{"url":"https://api.github.com/repos/rust-lang/cargo/issues/comments/234301506","html_url":"https://github.com/rust-lang/cargo/issues/2898#issuecomment-234301506","issue_url":"https://api.github.com/repos/rust-lang/cargo/issues/2898","id":234301506,"user":{"login":"Osspial","id":16296823,"avatar_url":"https://avatars.githubusercontent.com/u/16296823?v=3","gravatar_id":"","url":"https://api.github.com/users/Osspial","html_url":"https://github.com/Osspial","followers_url":"https://api.github.com/users/Osspial/followers","following_url":"https://api.github.com/users/Osspial/following{/other_user}","gists_url":"https://api.github.com/users/Osspial/gists{/gist_id}","starred_url":"https://api.github.com/users/Osspial/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Osspial/subscriptions","organizations_url":"https://api.github.com/users/Osspial/orgs","repos_url":"https://api.github.com/users/Osspial/repos","events_url":"https://api.github.com/users/Osspial/events{/privacy}","received_events_url":"https://api.github.com/users/Osspial/received_events","type":"User","site_admin":false},"created_at":"2016-07-21T16:05:02Z","updated_at":"2016-07-21T16:05:02Z","body":"I'm running Windows 7 Powershell. Interestingly, pass-through actually works if I'm doing it through cmd and not Powershell, so it seems that it *is* in fact an issue with Powershell interpreting the flags differently than other shells."}}
{"actor":{"display_login":"Osspial"}}