Skip to content

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

Open

Description

@liby

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions