Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage example file_size flag has problem #675

Open
yorkz1994 opened this issue Sep 11, 2024 · 0 comments
Open

storage example file_size flag has problem #675

yorkz1994 opened this issue Sep 11, 2024 · 0 comments

Comments

@yorkz1994
Copy link

When I run storage example with flag --size-gb, it always panic no matter what number is set.

./storage --dir /test --size-gb 10
...
Mismatch between definition and access of `file_size`. Could not downcast to TypeId { t: (11446210613632762899, 3222440509213045925) }, need to downcast to TypeId { t: (32853015933574672, 13565291224083057261) }

It turns out that the file_size flag definition has problem.
It misses clap value_parser to convert the input number from string to u64.

The fix is to add value_parser like below:

diff --git a/examples/storage.rs b/examples/storage.rs
index 8beb8ed..de6d7e9 100644
--- a/examples/storage.rs
+++ b/examples/storage.rs
@@ -1,5 +1,5 @@
 use byte_unit::{Byte, UnitType};
-use clap::{Arg, Command};
+use clap::{value_parser, Arg, Command};
 use futures_lite::{
     stream::{self, StreamExt},
     AsyncReadExt, AsyncWriteExt,
@@ -297,6 +297,7 @@ fn main() {
                 .long("size-gb")
                 .action(clap::ArgAction::Set)
                 .required(false)
+                .value_parser(value_parser!(u64))
                 .help("size of the file in GB (default: 2 * memory_size)"),
         )
         .get_matches();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant