#cli does not seem to work

3 messages · Page 1 of 1 (latest)

ionic garden
#

Hey folks,
I have build a normal Tauri application and would like to add some way to interact via cli with it.
For now I added a very simple subcommand to the tauri.conf.json, like so:

...
    "cli": {
      "description": "Small cli to interact with a running app",
      "subcommands": {
        "toggle-pause": {
          "description": "Toggles play/pause"
        }
      }
    },
...

For now I just want to get a print statement, when the code is called. So I added this small snippet to my app setup:

    let app = tauri::Builder::default()
        .setup(|app| {
            if let Ok(Matches {
                subcommand: Some(matches),
                ..
            }) = app.get_cli_matches()
            {
                if matches.name == "toggle-pause" {
                    println!("Jup");
                }
            };

            Ok(())
        })
        .build(tauri::generate_context!())
        .expect("error while running tauri application");

// app.run(...

However whenever I run the app in any way from the cli via ./myApp' another GUI instance is started. What I would like to achieve is, that running the app without subcommand starts the GUI, while adding args like --help` or my custom subcommand should invoke the cli and ideally interact with an already running instance of the app.

Is there an easy way to do this with Tauri or would I need to add addtional IPC between the cli and GUI instances? And how can I suppress the GUI opening?

Thanks in advance 🙂

white rivet
#

Interacting with other running instances there's nothing built into Tauri to manage, at least not that I have any knowledge of. So you'd need to set up additional IPC for that yourself :\