-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb8463b
commit 3837704
Showing
8 changed files
with
231 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use clap::{Parser, Subcommand}; | ||
|
||
#[derive(Parser, Debug, Clone, Copy)] | ||
#[command(author, version, about, long_about = None)] | ||
pub struct Cli { | ||
#[arg(short, long)] | ||
pub verbose: bool, | ||
|
||
#[command(subcommand)] | ||
pub command: Option<Commands>, | ||
} | ||
|
||
#[derive(Subcommand, Debug, Clone, Copy)] | ||
pub enum Commands { | ||
Mod { | ||
#[command(subcommand)] | ||
command: Option<ModCommands>, | ||
}, | ||
|
||
Instance { | ||
#[command(subcommand)] | ||
command: Option<InstanceCommands>, | ||
}, | ||
} | ||
|
||
#[derive(Subcommand, Debug, Clone, Copy)] | ||
pub enum ModCommands { | ||
Install { | ||
id: i32, | ||
instance_id: Option<i32>, | ||
}, | ||
|
||
Info { | ||
id: i32, | ||
instance_id: Option<i32>, | ||
}, | ||
|
||
Remove { | ||
id: i32, | ||
instance_id: Option<i32>, | ||
}, | ||
} | ||
|
||
#[derive(Subcommand, Debug, Clone, Copy)] | ||
pub enum InstanceCommands { | ||
List {}, | ||
Create {}, | ||
Delete {}, | ||
Info {}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod mods; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use wormhole_common::{installer::mods::ModInstaller, finder::find_install_dir}; | ||
|
||
pub async fn install_mod(id: i32, verbose: bool) { | ||
if verbose { | ||
println!("Creating mod installer..."); | ||
} | ||
|
||
let installer = ModInstaller::new(find_install_dir()); | ||
|
||
if verbose { | ||
println!("Installing mod..."); | ||
} | ||
|
||
installer.install_from_spacedock(id).await; | ||
|
||
if verbose { | ||
println!("Mod installed!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod install; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,35 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
pub mod cli; | ||
pub mod commands; | ||
|
||
use clap::Parser; | ||
use cli::{Cli, Commands, ModCommands}; | ||
use commands::mods::install::install_mod; | ||
use tokio::main; | ||
|
||
#[main] | ||
pub async fn main() { | ||
let cli = Cli::parse(); | ||
let verbose = cli.verbose; | ||
|
||
if verbose { | ||
println!("Command: {:?}", cli.command); | ||
} | ||
|
||
if let Some(scmd) = cli.command { | ||
match scmd { | ||
Commands::Mod { command } => { | ||
if let Some(scmd) = command { | ||
match scmd { | ||
ModCommands::Install { id, instance_id } => { | ||
install_mod(id, verbose).await; | ||
}, | ||
|
||
_ => (), | ||
}; | ||
} | ||
}, | ||
|
||
_ => (), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters