Skip to content

Commit

Permalink
Added scaffolding for import/export functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ekx committed Apr 25, 2024
1 parent d199f1e commit b1d47e7
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ cargo install starch
## Usage
```
starch update-cores
//TODO: starch export 'Sony - PlayStation/Tony Hawk's Pro Skater 2 (USA)'
//TODO: starch import 'Nintendo - Super Nintendo Entertainment System/Marvelous - Mouhitotsu no Takara-jima (Japan)'
//TODO: starch export 'Sony - PlayStation' 'Tony Hawk's Pro Skater 2 (USA)'
//TODO: starch import 'Nintendo - Super Nintendo Entertainment System' 'Marvelous - Mouhitotsu no Takara-jima (Japan)'
```
Detailed usage instruction can be queried with `-h` or `--help`

Expand Down
14 changes: 14 additions & 0 deletions src/import_export/export.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use crate::import_export::dummy_print;

use std::path::PathBuf;

pub(crate) fn export(
playlist: &String,
game: &String,
destination: &Option<PathBuf>,
retro_arch_path: &Option<PathBuf>,
) -> anyhow::Result<()> {
dummy_print(playlist, game, destination, retro_arch_path);

Ok(())
}
14 changes: 14 additions & 0 deletions src/import_export/import.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use crate::import_export::dummy_print;

use std::path::PathBuf;

pub(crate) fn import(
playlist: &String,
game: &String,
origin: &Option<PathBuf>,
retro_arch_path: &Option<PathBuf>,
) -> anyhow::Result<()> {
dummy_print(playlist, game, origin, retro_arch_path);

Ok(())
}
8 changes: 8 additions & 0 deletions src/import_export/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub mod export;
pub mod import;

use std::path::PathBuf;

fn dummy_print(arg1: &String, arg2: &String, arg3: &Option<PathBuf>, arg4: &Option<PathBuf>) {
println!("{}{}{:?}{:?}", arg1, arg2, arg3, arg4);
}
67 changes: 66 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
mod import_export;
mod update_cores;

use crate::import_export::export::export;
use crate::import_export::import::import;
use crate::update_cores::update_cores;

use std::path::PathBuf;

use anyhow::Result;
Expand Down Expand Up @@ -30,6 +35,50 @@ enum Commands {
)]
retro_arch_path: Option<PathBuf>,
},

#[command(about = "Exports a game from RetroArch to a removable media")]
Export {
#[arg(help = "Playlist to export from", required = true)]
playlist: String,

#[arg(help = "Game to be exported", required = true)]
game: String,

#[arg(
help = "Export destination path [default: first available removable media]",
required = false
)]
destination: Option<PathBuf>,

#[arg(
short,
long,
help = "Manually override RetroArch path (Will be queried from Steam otherwise)"
)]
retro_arch_path: Option<PathBuf>,
},

#[command(about = "Imports a game from a removable media to RetroArch")]
Import {
#[arg(help = "Playlist to import into", required = true)]
playlist: String,

#[arg(help = "Game to be imported", required = true)]
game: String,

#[arg(
help = "Import origin path [default: first available removable media]",
required = false
)]
origin: Option<PathBuf>,

#[arg(
short,
long,
help = "Manually override RetroArch path (Will be queried from Steam otherwise)"
)]
retro_arch_path: Option<PathBuf>,
},
}

#[tokio::main]
Expand All @@ -41,7 +90,23 @@ async fn main() -> Result<()> {
version,
retro_arch_path,
}) => {
update_cores::update_cores(version.to_owned(), retro_arch_path.to_owned()).await?;
update_cores(version.to_owned(), retro_arch_path.to_owned()).await?;
}
Some(Commands::Export {
playlist,
game,
destination,
retro_arch_path,
}) => {
export(playlist, game, destination, retro_arch_path)?;
}
Some(Commands::Import {
playlist,
game,
origin,
retro_arch_path,
}) => {
import(playlist, game, origin, retro_arch_path)?;
}
None => {}
}
Expand Down

0 comments on commit b1d47e7

Please sign in to comment.