Skip to content

Commit

Permalink
💫 Improve errors, partial impl of capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixr-codes committed May 9, 2024
1 parent 2c5e1a6 commit d15f239
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{collections::HashMap, path::PathBuf};

use crate::{
localization::{Language, LanguageGroups, OptionallyLocalized},
manifest::BaseGameVersion,
manifest::{BaseGameVersion, Capabilities},
};
use serde::Deserialize;

Expand Down Expand Up @@ -71,6 +71,10 @@ pub struct Config {
#[serde(rename = "WT")]
#[serde(default)]
pub wt: WT,

/// Section containing optional features that can be enabled in Minecraft.
#[serde(default)]
pub capabilities: Option<Capabilities>,
}

impl Config {
Expand Down
5 changes: 3 additions & 2 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl Manifest {
Pack::Skin => None,
Pack::WorldTemplate => None,
},
capabilities: None, // TODO
capabilities: project.config.capabilities, // FIXME: doesn't work; TODO: does this apply for all pack kinds?
metadata: Some(Metadata {
authors: project.config.project.authors,
license: project.config.project.license,
Expand Down Expand Up @@ -289,12 +289,13 @@ pub enum Language {
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(rename_all(deserialize = "kebab-case"))]
pub struct Capabilities {
/// The pack can add, remove, or modify chemistry behavior.
pub chemistry: bool,

/// Indicates that this pack contains extensions for editing.
#[serde(rename = "editorExtension")]
#[serde(rename(serialize = "editorExtension"))]
pub editor_extension: bool,

/// The pack can use HTML files to create custom UI, as well as use
Expand Down
10 changes: 7 additions & 3 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ impl From<&config::Plugin> for ExecutablePlugin {
};
match &value.args {
config::PluginArgs::Options(options) => {
args.push(serde_json::to_string(&options).expect("TODO"));
args.push(
serde_json::to_string(&options)
.expect("failed to transform TOML to JSON"),
);
}
config::PluginArgs::Args(a) => args.extend(a.to_vec()),
};
Expand All @@ -65,10 +68,11 @@ impl Plugin for ExecutablePlugin {
let mut cmd = Command::new(&self.program);
let cmd = cmd.args(&self.args).envs(env_vars);
let output = cmd.output()?;
let name = self.name().unwrap_or("<unnamed>".to_string());
if output.status.success() {
log::info!("Successfully run plugin {}", "TODO");
log::info!("Successfully run plugin {}", &name);
} else {
log::error!("Plugin {} did not run successful", "TODO");
log::error!("Plugin {} did not run successful", &name);
}
Ok(output.stdout)
}
Expand Down

0 comments on commit d15f239

Please sign in to comment.