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

Day 20: CLI Arguments and Logging, a issue with the chapter #8

Open
liby opened this issue Mar 13, 2022 · 0 comments
Open

Day 20: CLI Arguments and Logging, a issue with the chapter #8

liby opened this issue Mar 13, 2022 · 0 comments

Comments

@liby
Copy link
Contributor

liby commented Mar 13, 2022

As mentioned in the section on Adding CLI Arguments

  • follow the steps and you will see the following output on the command line
cargo run -p cli -- --help
wasm-runner 0.1.0
Sample project from https://vino.dev/blog/node-to-rust-day-1-rustup/

USAGE:
    cli

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
The example code at this point should look like this
  use my_lib::Module;
  use structopt::{clap::AppSettings, StructOpt};

  #[macro_use]
  extern crate log;

  #[derive(StructOpt)]
  #[structopt(
      name = "wasm-runner",
      about = "Sample project from https://vino.dev/blog/node-to-rust-day-1-rustup/",
      global_settings(&[
          AppSettings::ColoredHelp
      ]),
  )]
  struct CliOptions {}

  fn main() {
      env_logger::init();
      debug!("Initialized logger");

      match Module::from_file("./module.wasm") {
          Ok(_) => {
              info!("Module loaded");
          }
          Err(e) => {
              error!("Module failed to load: {}", e);
          }
      }
  }

Now when we run our cli we see… nothing at all.

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