Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Unclear global variables usage (need examples) #30

Open
apiraino opened this issue Dec 19, 2018 · 2 comments
Open

Unclear global variables usage (need examples) #30

apiraino opened this issue Dec 19, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@apiraino
Copy link

apiraino commented Dec 19, 2018

Consider this simple snippet:

use thunder;
use clap;
use thunder::thunderclap;
struct MyApp;
#[thunderclap(param: String: "A global var")]
impl MyApp {
    /// Scan a directory
    fn scan(source_dir: String) {
        println!("param={}", param);
    }
}
fn main() {
    MyApp::start();
}

returns an error when running compiling:

$ cargo run 
   Compiling test-thunder v0.1.0 (/home/xxx/tmp/test-thunder)
error[E0425]: cannot find value `param` in this scope
 --> src/main.rs:8:1
  |
8 | #[thunderclap(param: String: "A global var")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

or also

$ cargo run --param hey
error: Found argument '--param' which wasn't expected, or isn't valid in this context

USAGE:
    cargo run [OPTIONS] [--] [args]...

For more information try --help

How are global variable supposed to be used? Can you help with some more detailed examples?

thanks

@spacekookie spacekookie added the bug Something isn't working label Dec 19, 2018
@spacekookie
Copy link
Collaborator

Hey there!

Thanks for reporting this issue. I have to admit, I haven't used this code in a while but I'll try to have a look at what's going on here soon.

Also, just as general advice: if you want to run something via cargo and give it parameters, you need to escape them via -- first. So it would be: cargo run -- --param hey.

@apiraino
Copy link
Author

yeah, I forgot to mention that I've also tried cargo run -- --param hey but same results

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants