1use anyhow::{anyhow, Result};
2
3use crate::client::RommClient;
4use crate::commands::{api, download, platforms, roms, Commands, OutputFormat};
5
6pub async fn run(command: Commands, client: &RommClient, global_json: bool) -> Result<()> {
8 match command {
9 Commands::Api(cmd) => {
10 let format = OutputFormat::from_flags(global_json, false);
11 api::handle(cmd, client, format).await
12 }
13 Commands::Platforms(cmd) => {
14 let format = OutputFormat::from_flags(global_json, cmd.json);
15 platforms::handle(cmd, client, format).await
16 }
17 Commands::Roms(cmd) => {
18 let format = OutputFormat::from_flags(global_json, cmd.json);
19 roms::handle(cmd, client, format).await
20 }
21 Commands::Download(cmd) => download::handle(cmd, client).await,
22 Commands::Init(_) => Err(anyhow!(
23 "internal routing error: init command in CLI frontend"
24 )),
25 Commands::Tui => Err(anyhow!(
26 "internal routing error: TUI command in CLI frontend"
27 )),
28 Commands::Update => crate::commands::update::handle(),
29 }
30}