[3.0.0-beta.1] Non-unique arguments runtime panic #1969
-
I'm struggling to port my clap arguments from 2.33.1 to 3.0.0-beta.1 and I'm not sure if I'm encountering a bug or if I've messed up something syntactically. It might be a good to improve the error message if its working as intended. Here's my main function that compiles and runs in 2.3.3.1: extern crate clap;
use clap::{crate_version, App, Arg};
use headless_chrome::{protocol::page::ScreenshotFormat, Browser};
fn main() -> Result<(), failure::Error> {
let args = App::new("shotweb")
.about("Take screenshots of Chrome-rendered webpages.")
.version(crate_version!())
.arg(Arg::with_name("url")
.help("URL or file to take a screencap of. i.e. https://example.com or file:///path/to/file.html")
.index(1)
.required(true))
.arg(Arg::with_name("output-path")
.help("Local file path to save screenshot image to.")
.short("o")
.takes_value(true)
.default_value("/tmp/screenshot.png"))
.arg(Arg::with_name("element")
.help("CSS selector of element to screenshot.")
.short("e")
.takes_value(true))
.arg(Arg::with_name("image-format")
.help("Local file path to save screenshot image to.")
.short("i")
.takes_value(true)
.default_value("png")
.possible_values(&["png", "jpg"]))
.get_matches();
let url: &str = args.value_of("url").unwrap();
let output_path: &str = args.value_of("output-path").unwrap();
let img = screenshot_webpage(url)?;
std::fs::write(output_path, img)?;
Ok(())
} And here is my v3 attempt: use clap::{crate_version, App, Arg};
use headless_chrome::{protocol::page::ScreenshotFormat, Browser};
fn main() -> Result<(), failure::Error> {
let args = App::new("shotweb")
.about("Take screenshots of Chrome-rendered webpages.")
.version(crate_version!())
.arg(Arg::new("url")
.about("URL or file to take a screencap of. i.e. https://example.com or file:///path/to/file.html")
.index(1)
.required(true))
.arg(Arg::new("output-path")
.about("Local file path to save screenshot image to.")
.short('o')
.takes_value(true)
.default_value("/tmp/screenshot.png"))
.arg(Arg::new("element")
.about("CSS selector of element to screenshot.")
.short('e')
.takes_value(true))
.arg(Arg::new("image-format")
.about("Local file path to save screenshot image to.")
.short('i')
.takes_value(true)
.default_value("png")
.possible_values(&["png", "jpg"]))
.get_matches();
let url: &str = args.value_of("url").unwrap();
let output_path: &str = args.value_of("output-path").unwrap();
let img = screenshot_webpage(url)?;
std::fs::write(output_path, img)?;
Ok(())
} which returns a not-very-enlightening error at runtime:
Is anyone able to spot the issue I'm having? In the v3 beta version I've also moved it back into main, in case there was for some reason something strange with dropping get_matches into its own function. Any advice is appreciated! Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 4 replies
-
You are following master branch README for Additionally, I would suggest you to wait for v3 to come out properly because we still plan to break more things. |
Beta Was this translation helpful? Give feedback.
-
The whole point of beta releases is that users can try out and report bugs before the main version is released. If this wasn't the motivation of pushing for beta releases, then I don't understand the significance of having the beta release |
Beta Was this translation helpful? Give feedback.
-
Let me clarify a bit more. Please wait for 3.0 before using clap in Production. The beta releases as advertised are just for trying out. |
Beta Was this translation helpful? Give feedback.
-
I forgot I was going to ask: should I file a bug about the error I encountered above, or is this issue already known and being addressed in the pipeline? |
Beta Was this translation helpful? Give feedback.
-
This is not a bug. You were just mixing up the versions. We already addressed it. |
Beta Was this translation helpful? Give feedback.
-
To clarify, you were using code shown in master README with 3.0.0-beta.1 which shouldn't work because there are some breaking changes in master. |
Beta Was this translation helpful? Give feedback.
-
I compiled and ran this code using |
Beta Was this translation helpful? Give feedback.
-
Yeah. That is what I meant in
Let me edit that comment with more clarity since there seems to be misunderstanding. |
Beta Was this translation helpful? Give feedback.
-
Got it, understood! Thanks for the info. 🙂 |
Beta Was this translation helpful? Give feedback.
-
I don't think we should do it. I want to finish off all the planned
breaking changes before the next release (rc) and ask people for feedback.
…On Wed, Jun 17, 2020, 01:57 CreepySkeleton ***@***.***> wrote:
I suppose he best solution would be to make a point release (also beta)
that will bring the README and examples on par with latest crates.io
release. @pksunkara <https://github.com/pksunkara> @kbknapp
<https://github.com/kbknapp> Any objections?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1969 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABKU34PC7QT6L3IE4DZSXLRXABFNANCNFSM4NZDEIAA>
.
|
Beta Was this translation helpful? Give feedback.
-
3.0.0-beta.1 is not broken. You were just following the wrong examples. If
you go to the examples folder of that tag on GitHub and follow them, it
will work.
On Wed, Jun 17, 2020, 09:50 Pavan Kumar Sunkara <[email protected]>
wrote:
… I don't think we should do it. I want to finish off all the planned
breaking changes before the next release (rc) and ask people for feedback.
On Wed, Jun 17, 2020, 01:57 CreepySkeleton ***@***.***>
wrote:
> I suppose he best solution would be to make a point release (also beta)
> that will bring the README and examples on par with latest crates.io
> release. @pksunkara <https://github.com/pksunkara> @kbknapp
> <https://github.com/kbknapp> Any objections?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1969 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABKU34PC7QT6L3IE4DZSXLRXABFNANCNFSM4NZDEIAA>
> .
>
|
Beta Was this translation helpful? Give feedback.
You are following master branch README for
3.0.0-beta.1
release. It will not work because there is a breaking change in the master branch after3.0.0-beta.1
was released. Please check out the tag and then follow the README if you want to try out the beta.Additionally, I would suggest you to wait for v3 to come out properly because we still plan to break more things.