change project name from shulkerscript to shulkerscript-cli

This commit is contained in:
Moritz Hölting 2024-06-12 18:27:33 +02:00
parent 3c279083c7
commit 141cdb2648
9 changed files with 21 additions and 45 deletions

View File

@ -1,5 +1,5 @@
[package] [package]
name = "shulkerscript" name = "shulkerscript-cli"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
@ -12,10 +12,14 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "shulkerscript"
path = "src/main.rs"
[features] [features]
default = ["zip", "lua"] default = ["zip", "lua"]
lang-debug = [] lang-debug = []
lua = ["shulkerscript-lang/lua"] lua = ["shulkerscript/lua"]
zip = ["shulkerbox/zip"] zip = ["shulkerbox/zip"]
[dependencies] [dependencies]
@ -24,7 +28,7 @@ colored = "2.1.0"
serde = { version = "1.0.197", features = ["derive"] } serde = { version = "1.0.197", features = ["derive"] }
thiserror = "1.0.58" thiserror = "1.0.58"
toml = "0.8.12" 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" } shulkerbox = { git = "https://github.com/moritz-hoelting/shulkerbox", default-features = false, rev = "b79c9ecd6d45f9319c9083a8103ef0186839b0c0" }
git2 = { version = "0.18.3", default-features = false } git2 = { version = "0.18.3", default-features = false }
path-absolutize = "3.1.1" path-absolutize = "3.1.1"

View File

@ -7,11 +7,6 @@ pub struct ProjectConfig {
pub pack: PackConfig, pub pack: PackConfig,
pub compiler: Option<CompilerConfig>, pub compiler: Option<CompilerConfig>,
} }
impl ProjectConfig {
pub fn new(pack: PackConfig, compiler: Option<CompilerConfig>) -> Self {
Self { pack, compiler }
}
}
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PackConfig { pub struct PackConfig {
@ -26,16 +21,6 @@ pub struct PackConfig {
pub version: String, 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 { impl Default for PackConfig {
fn default() -> Self { fn default() -> Self {
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. /// The path of a folder which files and subfolders will be copied to the root of the datapack.
pub assets: Option<PathBuf>, pub assets: Option<PathBuf>,
} }
impl CompilerConfig {
pub fn new(assets: Option<PathBuf>) -> Self {
Self { assets }
}
}

View File

@ -1,5 +1,6 @@
use std::path::PathBuf; use std::path::PathBuf;
#[allow(clippy::enum_variant_names)]
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum Error { pub enum Error {
#[error("No file/directory found at path {0}.")] #[error("No file/directory found at path {0}.")]
@ -12,4 +13,5 @@ pub enum Error {
InvalidPackPathError(PathBuf), InvalidPackPathError(PathBuf),
} }
#[allow(dead_code)]
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;

View File

@ -1,6 +0,0 @@
pub mod cli;
pub mod config;
pub mod error;
pub mod subcommands;
pub mod terminal_output;
pub mod util;

View File

@ -1,7 +1,13 @@
mod cli;
mod config;
mod error;
mod subcommands;
mod terminal_output;
use std::process::ExitCode; use std::process::ExitCode;
use clap::Parser; use clap::Parser;
use shulkerscript::cli::Args; use cli::Args;
fn main() -> ExitCode { fn main() -> ExitCode {
color_eyre::install().unwrap(); color_eyre::install().unwrap();

View File

@ -49,7 +49,7 @@ pub fn build(_verbose: bool, args: &BuildArgs) -> Result<()> {
.join("src"), .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"); let icon_path = toml_path.parent().unwrap().join("pack.png");

View File

@ -27,7 +27,7 @@ pub enum DumpState {
pub fn lang_debug(args: &LangDebugArgs) -> Result<()> { pub fn lang_debug(args: &LangDebugArgs) -> Result<()> {
match args.dump { match args.dump {
DumpState::Tokens => { DumpState::Tokens => {
let tokens = shulkerscript_lang::tokenize(&args.path)?; let tokens = shulkerscript::tokenize(&args.path)?;
if args.pretty { if args.pretty {
println!("{:#?}", tokens); println!("{:#?}", tokens);
} else { } else {
@ -35,7 +35,7 @@ pub fn lang_debug(args: &LangDebugArgs) -> Result<()> {
} }
} }
DumpState::Ast => { DumpState::Ast => {
let ast = shulkerscript_lang::parse(&args.path)?; let ast = shulkerscript::parse(&args.path)?;
if args.pretty { if args.pretty {
println!("{:#?}", ast); println!("{:#?}", ast);
} else { } else {
@ -44,7 +44,7 @@ pub fn lang_debug(args: &LangDebugArgs) -> Result<()> {
} }
DumpState::Datapack => { DumpState::Datapack => {
let program_paths = super::build::get_script_paths(&args.path.join("src"))?; 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 { if args.pretty {
println!("{:#?}", datapack); println!("{:#?}", datapack);
} else { } else {

View File

@ -40,7 +40,7 @@ pub fn package(_verbose: bool, args: &PackageArgs) -> Result<()> {
.join("src"), .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"); let icon_path = toml_path.parent().unwrap().join("pack.png");

View File

@ -1,9 +0,0 @@
use std::{io, path::Path};
pub fn to_absolute_path(path: &Path) -> io::Result<String> {
Ok(std::fs::canonicalize(path)?
.display()
.to_string()
.trim_start_matches(r"\\?\")
.to_string())
}