Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game registration refactor and improvements #4

Merged
merged 8 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 51 additions & 83 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ base64 = "0.21"
walkdir = "2.3"
zip = "0.6"
directories = "5.0"
steamlocate = "2.0.0-alpha.0"
steamlocate = "2.0.0-beta.2"

sysinfo = "0.29"

Expand Down
24 changes: 17 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,33 +157,43 @@ pub enum Commands {
},

/// Imports a new game for use by tcli.
ImportGame {
Import {
/// The identifier of the game to import.
///
/// Use the `list` command to query the list of imported and supported games.
#[clap(long, short)]
game_id: String,

/// The platform to import the game from. Leave blank to have tcli decide for you.
///
/// Use the `list` command to query the list of supported platforms for your game.
#[clap(long)]
platform: Option<String>,

#[clap(long)]
/// The custom identifier this game will be referenced by.
/// The custom identifier this game will be referred to.
custom_id: Option<String>,

#[clap(long)]
/// The custom name this game will be displayed as.
custom_name: Option<String>,

/// Path to the game executable to use when launching the game. Only works with servers.
#[clap(long, required_if_eq("platform", "nodrm"))]
game_dir: Option<PathBuf>,

#[clap(long, requires("platform"))]
steam_dir: Option<PathBuf>,

/// URL of the default repository.
#[clap(long)]
exe_path: Option<PathBuf>,
repository: Option<String>,

/// Directory where tcli keeps its data.
/// %APPDATA%/Roaming/tcli on Windows, ~/.config/tcli on Linux.
#[clap(long)]
tcli_directory: Option<PathBuf>,

/// URL of the default repository.
#[clap(long)]
repository: Option<String>,

/// Path of the project configuration file.
#[clap(long, default_value = DEFAULT_MANIFEST)]
project_path: PathBuf,
Expand Down
20 changes: 13 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ use crate::ts::version::Version;
#[derive(Debug, thiserror::Error)]
#[repr(u32)]
pub enum Error {
#[error("An API error occured.")]
#[error("An API error occurred.")]
ApiError {
source: reqwest::Error,
response_body: Option<String>,
} = 1,

#[error("A game import error occurred.")]
GameImportError(#[from] crate::game::import::Error),

#[error("The file at {0} does not exist or is otherwise not accessible.")]
FileNotFound(PathBuf),

Expand Down Expand Up @@ -85,18 +88,21 @@ pub enum Error {
},

#[error(
"
The installer '{package_id}' did not respond correctly:
{message}
"
"The installer '{package_id}' did not respond correctly:
\t{message}"
)]
InstallerBadResponse { package_id: String, message: String },

#[error("The installer returned an error:\n\t{message}")]
InstallerError { message: String },

#[error("The provided game id '{0}' does not exist or has not been imported into this profile.")]
BadGameId(String)
#[error(
"The provided game id '{0}' does not exist or has not been imported into this profile."
)]
BadGameId(String),

#[error("The Steam app with id '{0}' could not be found.")]
SteamAppNotFound(u32),
}

pub trait IoResultToTcli<R> {
Expand Down
Loading
Loading