Skip to content

[docs] Making Your Own CLI is incorrect #4145

@DoodlesEpic

Description

@DoodlesEpic

https://tauri.studio/v1/guides/features/cli/#rust
On the documentation the page Making Your Own CLI has a section for reading matches with Rust, with the following code example:

use tauri::api::cli::get_matches;

fn main() {
  let context = tauri::generate_context!();
  let cli_config = context.config().tauri.cli.clone().unwrap();

  match get_matches(&cli_config) {
    // `matches` here is a Struct with { args, subcommand }.
    // `args` is `HashMap<String, ArgData>` where `ArgData` is a struct with { value, occurances }.
    // `subcommand` is `Option<Box<SubcommandMatches>>` where `SubcommandMatches` is a struct with { name, matches }.
    Ok(matches) => {
      println!("{:?}", matches)
    }
    Err(_) => {}
  };

  tauri::Builder::default()
  .run(context)
  .expect("error while running tauri application");
}

This code however is incorrect since the signature of the function get_matches has been changed and now requires two arguments:

pub fn get_matches(cli: &CliConfig, package_info: &PackageInfo) -> crate::api::Result<Matches>

Trying to compile this will result in the following error:

error[E0061]: this function takes 2 arguments but 1 argument was supplied
  --> src/main.rs:12:11
   |
12 |     match get_matches(&cli_config) {
   |           ^^^^^^^^^^^ ----------- supplied 1 argument
   |           |
   |           expected 2 arguments
   |
note: function defined here
  --> /home/doodles/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-1.0.0-rc.10/src/api/cli.rs:97:8
   |
97 | pub fn get_matches(cli: &CliConfig, package_info: &PackageInfo) -> crate::api::Result<Matches> {
   |        ^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions