diff --git a/Cargo.toml b/Cargo.toml index 6ecc833..11ca95a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "shulkerscript" +name = "shulkerscript-cli" version = "0.1.0" edition = "2021" @@ -12,10 +12,14 @@ license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "shulkerscript" +path = "src/main.rs" + [features] default = ["zip", "lua"] lang-debug = [] -lua = ["shulkerscript-lang/lua"] +lua = ["shulkerscript/lua"] zip = ["shulkerbox/zip"] [dependencies] @@ -24,7 +28,7 @@ colored = "2.1.0" serde = { version = "1.0.197", features = ["derive"] } thiserror = "1.0.58" toml = "0.8.12" -shulkerscript-lang = { git = "https://github.com/moritz-hoelting/shulkerscript-lang", features = ["shulkerbox"], default-features = false, rev = "899a973315ce63ff20c789a7e7a784e926efc027"} +shulkerscript = { git = "https://github.com/moritz-hoelting/shulkerscript-lang", features = ["shulkerbox"], default-features = false, rev = "5336ffb91ed5dfa1b2fce3993d84a2876aa732a3" } shulkerbox = { git = "https://github.com/moritz-hoelting/shulkerbox", default-features = false, rev = "b79c9ecd6d45f9319c9083a8103ef0186839b0c0" } git2 = { version = "0.18.3", default-features = false } path-absolutize = "3.1.1" diff --git a/src/config.rs b/src/config.rs index 2e85675..8fa2bc1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,11 +7,6 @@ pub struct ProjectConfig { pub pack: PackConfig, pub compiler: Option, } -impl ProjectConfig { - pub fn new(pack: PackConfig, compiler: Option) -> Self { - Self { pack, compiler } - } -} #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PackConfig { @@ -26,16 +21,6 @@ pub struct PackConfig { pub version: String, } -impl PackConfig { - pub fn new(name: &str, description: &str, pack_format: u8) -> Self { - Self { - name: name.to_string(), - description: description.to_string(), - pack_format, - version: "0.1.0".to_string(), - } - } -} impl Default for PackConfig { fn default() -> Self { Self { @@ -56,9 +41,3 @@ pub struct CompilerConfig { /// The path of a folder which files and subfolders will be copied to the root of the datapack. pub assets: Option, } - -impl CompilerConfig { - pub fn new(assets: Option) -> Self { - Self { assets } - } -} diff --git a/src/error.rs b/src/error.rs index 57b319c..2e5e484 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,6 @@ use std::path::PathBuf; +#[allow(clippy::enum_variant_names)] #[derive(thiserror::Error, Debug)] pub enum Error { #[error("No file/directory found at path {0}.")] @@ -12,4 +13,5 @@ pub enum Error { InvalidPackPathError(PathBuf), } +#[allow(dead_code)] pub type Result = std::result::Result; diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index add9d0f..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod cli; -pub mod config; -pub mod error; -pub mod subcommands; -pub mod terminal_output; -pub mod util; diff --git a/src/main.rs b/src/main.rs index 46bec68..8d972b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,13 @@ +mod cli; +mod config; +mod error; +mod subcommands; +mod terminal_output; + use std::process::ExitCode; use clap::Parser; -use shulkerscript::cli::Args; +use cli::Args; fn main() -> ExitCode { color_eyre::install().unwrap(); diff --git a/src/subcommands/build.rs b/src/subcommands/build.rs index 2f0276d..e5cad5a 100644 --- a/src/subcommands/build.rs +++ b/src/subcommands/build.rs @@ -49,7 +49,7 @@ pub fn build(_verbose: bool, args: &BuildArgs) -> Result<()> { .join("src"), )?; - let mut compiled = shulkerscript_lang::compile(&script_paths)?; + let mut compiled = shulkerscript::compile(&script_paths)?; let icon_path = toml_path.parent().unwrap().join("pack.png"); diff --git a/src/subcommands/lang_debug.rs b/src/subcommands/lang_debug.rs index 3eed643..da68912 100644 --- a/src/subcommands/lang_debug.rs +++ b/src/subcommands/lang_debug.rs @@ -27,7 +27,7 @@ pub enum DumpState { pub fn lang_debug(args: &LangDebugArgs) -> Result<()> { match args.dump { DumpState::Tokens => { - let tokens = shulkerscript_lang::tokenize(&args.path)?; + let tokens = shulkerscript::tokenize(&args.path)?; if args.pretty { println!("{:#?}", tokens); } else { @@ -35,7 +35,7 @@ pub fn lang_debug(args: &LangDebugArgs) -> Result<()> { } } DumpState::Ast => { - let ast = shulkerscript_lang::parse(&args.path)?; + let ast = shulkerscript::parse(&args.path)?; if args.pretty { println!("{:#?}", ast); } else { @@ -44,7 +44,7 @@ pub fn lang_debug(args: &LangDebugArgs) -> Result<()> { } DumpState::Datapack => { let program_paths = super::build::get_script_paths(&args.path.join("src"))?; - let datapack = shulkerscript_lang::transpile(&program_paths)?; + let datapack = shulkerscript::transpile(&program_paths)?; if args.pretty { println!("{:#?}", datapack); } else { diff --git a/src/subcommands/package.rs b/src/subcommands/package.rs index 457924b..b9ba460 100644 --- a/src/subcommands/package.rs +++ b/src/subcommands/package.rs @@ -40,7 +40,7 @@ pub fn package(_verbose: bool, args: &PackageArgs) -> Result<()> { .join("src"), )?; - let mut compiled = shulkerscript_lang::compile(&script_paths)?; + let mut compiled = shulkerscript::compile(&script_paths)?; let icon_path = toml_path.parent().unwrap().join("pack.png"); diff --git a/src/util.rs b/src/util.rs deleted file mode 100644 index 6c330b6..0000000 --- a/src/util.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::{io, path::Path}; - -pub fn to_absolute_path(path: &Path) -> io::Result { - Ok(std::fs::canonicalize(path)? - .display() - .to_string() - .trim_start_matches(r"\\?\") - .to_string()) -}