mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2025-12-16 09:28:53 +00:00
WIP
This commit is contained in:
parent
fb4e47eac7
commit
5da5987b6c
@ -3,16 +3,14 @@ use clap::Parser;
|
|||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
/// Pass launch options to tinker the behavior of the game, this parameter have priotiy over the
|
#[command(subcommand)]
|
||||||
/// --set-options param
|
pub command: Option<crate::commands::Commands>,
|
||||||
|
|
||||||
|
/// Pass launch options to tinker the behavior of the game, this parameter have priority over the
|
||||||
|
/// set-launch-options command
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub options: Option<String>,
|
pub options: Option<String>,
|
||||||
|
|
||||||
/// Set to the config launch options to tinker the behavior of the game, you need to run this
|
|
||||||
/// command one time to set your launch options to the configuration
|
|
||||||
#[arg(long)]
|
|
||||||
pub set_options: Option<String>,
|
|
||||||
|
|
||||||
/// Show the logs direcly to the stdout of your terminal
|
/// Show the logs direcly to the stdout of your terminal
|
||||||
#[arg(long, default_value = "false")]
|
#[arg(long, default_value = "false")]
|
||||||
pub logs: bool,
|
pub logs: bool,
|
||||||
|
|||||||
11
babylonia-terminal-cli/src/commands.rs
Normal file
11
babylonia-terminal-cli/src/commands.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
use clap::Subcommand;
|
||||||
|
|
||||||
|
#[derive(Debug, Subcommand)]
|
||||||
|
pub enum Commands {
|
||||||
|
/// Set to the config launch options to tinker the behavior of the game, you need to run this
|
||||||
|
/// command one time to set your launch options to the configuration
|
||||||
|
SetLaunchOptions { launch_options: String },
|
||||||
|
|
||||||
|
/// Set the current game directory, this command will move all the current game file to the new one!
|
||||||
|
SetGamePath { new_game_directory: String },
|
||||||
|
}
|
||||||
@ -1,14 +1,17 @@
|
|||||||
use babylonia_terminal_sdk::game_config::GameConfig;
|
use babylonia_terminal_sdk::game_config::GameConfig;
|
||||||
|
use babylonia_terminal_sdk::utils;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use log::{debug, LevelFilter};
|
use log::{debug, info, LevelFilter};
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
|
|
||||||
mod arguments;
|
mod arguments;
|
||||||
|
mod commands;
|
||||||
pub mod game;
|
pub mod game;
|
||||||
pub mod reporter;
|
pub mod reporter;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
use crate::arguments::Args;
|
use crate::arguments::Args;
|
||||||
|
use crate::commands::Commands;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
@ -29,11 +32,19 @@ async fn main() {
|
|||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
debug!("Launch option -> {:?}", args.options);
|
debug!("Launch option -> {:?}", args.options);
|
||||||
|
|
||||||
if let Some(command) = args.set_options {
|
match args.command {
|
||||||
GameConfig::set_launch_options(Some(command))
|
Some(Commands::SetLaunchOptions { launch_options }) => {
|
||||||
|
GameConfig::set_launch_options(Some(launch_options))
|
||||||
.await
|
.await
|
||||||
.expect("Failed to save launch options into the config file");
|
.expect("Failed to save launch options into the config file");
|
||||||
|
info!("Successfully updated launch options!");
|
||||||
|
}
|
||||||
|
Some(Commands::SetGamePath { new_game_directory }) => {
|
||||||
|
utils::fs::move_all_file_in_dir(
|
||||||
|
"~/.babylonia-terminal/PGR",
|
||||||
|
"~/.babylonia-terminal/PGR",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
None => game::run(args.options, args.logs).await,
|
||||||
}
|
}
|
||||||
|
|
||||||
game::run(args.options, args.logs).await;
|
|
||||||
}
|
}
|
||||||
|
|||||||
36
babylonia-terminal-sdk/src/utils/fs.rs
Normal file
36
babylonia-terminal-sdk/src/utils/fs.rs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
use std::{
|
||||||
|
path::PathBuf,
|
||||||
|
task::{Context, Poll},
|
||||||
|
};
|
||||||
|
|
||||||
|
use log::debug;
|
||||||
|
use tokio::fs;
|
||||||
|
|
||||||
|
pub async fn move_all_file_in_dir(dir: &PathBuf, new_dir: &PathBuf) -> Result<(), String> {
|
||||||
|
if !dir.is_dir() {
|
||||||
|
return Err(format!(
|
||||||
|
"{} is not a directory",
|
||||||
|
dir.as_os_str().to_str().unwrap()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if !dir.exists() {
|
||||||
|
return Err(format!(
|
||||||
|
"{} does not exist",
|
||||||
|
dir.as_os_str().to_str().unwrap()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(mut objects) = fs::read_dir(dir).await {
|
||||||
|
while let Ok(Some(entry)) = objects.next_entry().await {
|
||||||
|
debug!("{:?}", entry);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Err(format!(
|
||||||
|
"Failed to read directory -> {}",
|
||||||
|
dir.as_os_str().to_str().unwrap()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
pub mod fs;
|
||||||
pub mod github_requester;
|
pub mod github_requester;
|
||||||
pub mod kuro_prod_api;
|
pub mod kuro_prod_api;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user