refactor(vm): pull generated data into new crate
pregenerate prefab templates -> locked behind crate feature
This commit is contained in:
@@ -24,6 +24,17 @@ struct Args {
|
||||
|
||||
const PACKAGES: &[&str] = &["ic10lsp_wasm", "ic10emu_wasm"];
|
||||
const VALID_VERSION_TYPE: &[&str] = &["patch", "minor", "major"];
|
||||
const VALID_GENERATE_TYPE: &[&str] = &["enums", "instructions", "database"];
|
||||
const DEFAULT_GENERATE: &[&str] = &["enums"];
|
||||
fn parse_generate_modules(s: &str) -> Result<String, String> {
|
||||
if !VALID_GENERATE_TYPE.contains(&s) {
|
||||
let valid_str = VALID_GENERATE_TYPE.join(", ");
|
||||
return Err(format!(
|
||||
"{s} is not a valid generate module. One of: {valid_str}"
|
||||
));
|
||||
}
|
||||
Ok(s.to_string())
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
enum Task {
|
||||
@@ -54,6 +65,8 @@ enum Task {
|
||||
/// update changelog
|
||||
Changelog {},
|
||||
Generate {
|
||||
#[arg(long, short = 'm', value_delimiter = ',', default_values = DEFAULT_GENERATE, value_parser = parse_generate_modules)]
|
||||
modules: Vec<String>,
|
||||
#[arg()]
|
||||
/// Path to Stationeers installation. Used to locate "Stationpedia.json" and "Enums.json"
|
||||
/// generated by https://github.com/Ryex/StationeersStationpediaExtractor
|
||||
@@ -166,7 +179,7 @@ fn main() -> color_eyre::Result<()> {
|
||||
.status()
|
||||
.map_err(|e| Error::Command(format!("{}", cmd.get_program().to_string_lossy()), e))?;
|
||||
}
|
||||
Task::Generate { path } => {
|
||||
Task::Generate { modules, path } => {
|
||||
let path = match path {
|
||||
Some(path) => {
|
||||
let mut path = std::path::PathBuf::from(path);
|
||||
@@ -214,7 +227,11 @@ fn main() -> color_eyre::Result<()> {
|
||||
&& path.join("Stationpedia.json").exists()
|
||||
&& path.join("Enums.json").exists()
|
||||
{
|
||||
generate::generate(&path, &workspace)?;
|
||||
generate::generate(
|
||||
&path,
|
||||
&workspace,
|
||||
&modules.iter().map(String::as_str).collect::<Vec<_>>(),
|
||||
)?;
|
||||
} else {
|
||||
return Err(Error::BadStationeersPath(path).into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user