update shulkerscript-lang dependency
This commit is contained in:
parent
bc6975e52f
commit
4e5089bb89
|
@ -24,13 +24,13 @@ watch = ["dep:notify-debouncer-mini", "dep:ctrlc"]
|
||||||
zip = ["shulkerbox/zip"]
|
zip = ["shulkerbox/zip"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.4", features = ["derive", "env", "deprecated"] }
|
clap = { version = "4.5.4", features = ["deprecated", "derive", "env"] }
|
||||||
colored = "2.1.0"
|
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 = { git = "https://github.com/moritz-hoelting/shulkerscript-lang.git", features = ["shulkerbox"], default-features = false, rev = "a0a27cda96e1922b019b216961c39f7ef7991d22" }
|
shulkerscript = { git = "https://github.com/moritz-hoelting/shulkerscript-lang.git", features = ["fs_access", "shulkerbox"], default-features = false, rev = "0cccee936e427d8ac2238956d2ef7b240d568e13" }
|
||||||
shulkerbox = { git = "https://github.com/moritz-hoelting/shulkerbox.git", default-features = false, rev = "a2d20dab8ea97bbd873edafb23afaad34292457f" }
|
shulkerbox = { git = "https://github.com/moritz-hoelting/shulkerbox.git", default-features = false, rev = "aff342a64a94981af942223345b5a5f105212957" }
|
||||||
git2 = { version = "0.19.0", default-features = false }
|
git2 = { version = "0.19.0", default-features = false }
|
||||||
path-absolutize = "3.1.1"
|
path-absolutize = "3.1.1"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
|
@ -40,7 +40,7 @@ tracing = "0.1.40"
|
||||||
tracing-subscriber = "0.3.18"
|
tracing-subscriber = "0.3.18"
|
||||||
# waiting for pull request to be merged
|
# waiting for pull request to be merged
|
||||||
inquire = { git = "https://github.com/moritz-hoelting/rust-inquire.git", branch = "main", package = "inquire" }
|
inquire = { git = "https://github.com/moritz-hoelting/rust-inquire.git", branch = "main", package = "inquire" }
|
||||||
camino = "1.1.7"
|
|
||||||
human-panic = "2.0.0"
|
human-panic = "2.0.0"
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
pathdiff = "0.2.1"
|
pathdiff = "0.2.1"
|
||||||
|
const_format = "0.2.32"
|
||||||
|
|
|
@ -2,11 +2,18 @@ use crate::subcommands::{self, BuildArgs, CleanArgs, InitArgs};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{Parser, Subcommand, ValueEnum};
|
use clap::{Parser, Subcommand, ValueEnum};
|
||||||
|
use const_format::formatcp;
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
use tracing_subscriber::FmtSubscriber;
|
use tracing_subscriber::FmtSubscriber;
|
||||||
|
|
||||||
|
static VERSION: &str = formatcp!(
|
||||||
|
"v{cli_version}\nshulkerscript-lang v{lang_version}",
|
||||||
|
cli_version = env!("CARGO_PKG_VERSION"),
|
||||||
|
lang_version = shulkerscript::VERSION
|
||||||
|
);
|
||||||
|
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None, disable_version_flag = false, version = VERSION)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub struct PackConfig {
|
||||||
impl PackConfig {
|
impl PackConfig {
|
||||||
pub const DEFAULT_NAME: &'static str = "shulkerscript-pack";
|
pub const DEFAULT_NAME: &'static str = "shulkerscript-pack";
|
||||||
pub const DEFAULT_DESCRIPTION: &'static str = "A Minecraft datapack created with shulkerscript";
|
pub const DEFAULT_DESCRIPTION: &'static str = "A Minecraft datapack created with shulkerscript";
|
||||||
pub const DEFAULT_PACK_FORMAT: u8 = 48;
|
pub const DEFAULT_PACK_FORMAT: u8 = shulkerbox::datapack::Datapack::LATEST_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PackConfig {
|
impl Default for PackConfig {
|
||||||
|
|
30
src/lib.rs
30
src/lib.rs
|
@ -1,3 +1,33 @@
|
||||||
|
//! This crate is the cli app of the ShulkerScript language for creating Minecraft datapacks.
|
||||||
|
//!
|
||||||
|
//! # Installation
|
||||||
|
//! ```bash
|
||||||
|
//! cargo install shulkerscript-cli
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! # Usage
|
||||||
|
//! An extended description of the commands can be found in the readme or by running `shulkerscript --help`.
|
||||||
|
//!
|
||||||
|
//! ### Initialize a new project
|
||||||
|
//! ```bash
|
||||||
|
//! shulkerscript init [OPTIONS] [PATH]
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ### Build a project
|
||||||
|
//! ```bash
|
||||||
|
//! shulkerscript build [OPTIONS] [PATH]
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ### Clean the output directory
|
||||||
|
//! ```bash
|
||||||
|
//! shulkerscript clean [OPTIONS] [PATH]
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ### Watch for changes
|
||||||
|
//! ```bash
|
||||||
|
//! shulkerscript watch [OPTIONS] [PATH]
|
||||||
|
//! ```
|
||||||
|
|
||||||
pub mod cli;
|
pub mod cli;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use shulkerbox::{
|
||||||
util::compile::CompileOptions,
|
util::compile::CompileOptions,
|
||||||
virtual_fs::{VFile, VFolder},
|
virtual_fs::{VFile, VFolder},
|
||||||
};
|
};
|
||||||
use shulkerscript::base::FsProvider;
|
use shulkerscript::base::{FsProvider, PrintHandler};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::ProjectConfig,
|
config::ProjectConfig,
|
||||||
|
@ -76,6 +76,7 @@ pub fn build(args: &BuildArgs) -> Result<()> {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let datapack = shulkerscript::transpile(
|
let datapack = shulkerscript::transpile(
|
||||||
|
&PrintHandler::new(),
|
||||||
&FsProvider::default(),
|
&FsProvider::default(),
|
||||||
project_config.pack.pack_format,
|
project_config.pack.pack_format,
|
||||||
&script_paths,
|
&script_paths,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::ValueEnum;
|
use clap::ValueEnum;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use shulkerscript::base::FsProvider;
|
use shulkerscript::base::{FsProvider, PrintHandler};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::{config::PackConfig, util};
|
use crate::{config::PackConfig, util};
|
||||||
|
@ -33,7 +33,14 @@ pub fn lang_debug(args: &LangDebugArgs) -> Result<()> {
|
||||||
let file_provider = FsProvider::default();
|
let file_provider = FsProvider::default();
|
||||||
match args.dump {
|
match args.dump {
|
||||||
DumpState::Tokens => {
|
DumpState::Tokens => {
|
||||||
let tokens = shulkerscript::tokenize(&file_provider, &args.path)?;
|
let tokens = shulkerscript::tokenize(
|
||||||
|
&PrintHandler::new(),
|
||||||
|
&file_provider,
|
||||||
|
&args.path,
|
||||||
|
args.path.file_stem().map_or(String::from("main"), |s| {
|
||||||
|
s.to_string_lossy().into_owned().to_string()
|
||||||
|
}),
|
||||||
|
)?;
|
||||||
if args.pretty {
|
if args.pretty {
|
||||||
println!("{:#?}", tokens);
|
println!("{:#?}", tokens);
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,7 +48,14 @@ pub fn lang_debug(args: &LangDebugArgs) -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DumpState::Ast => {
|
DumpState::Ast => {
|
||||||
let ast = shulkerscript::parse(&file_provider, &args.path)?;
|
let ast = shulkerscript::parse(
|
||||||
|
&PrintHandler::new(),
|
||||||
|
&file_provider,
|
||||||
|
&args.path,
|
||||||
|
args.path.file_stem().map_or(String::from("main"), |s| {
|
||||||
|
s.to_string_lossy().into_owned().to_string()
|
||||||
|
}),
|
||||||
|
)?;
|
||||||
if args.pretty {
|
if args.pretty {
|
||||||
println!("{:#?}", ast);
|
println!("{:#?}", ast);
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,6 +69,7 @@ pub fn lang_debug(args: &LangDebugArgs) -> Result<()> {
|
||||||
.join("src"),
|
.join("src"),
|
||||||
)?;
|
)?;
|
||||||
let datapack = shulkerscript::transpile(
|
let datapack = shulkerscript::transpile(
|
||||||
|
&PrintHandler::new(),
|
||||||
&file_provider,
|
&file_provider,
|
||||||
PackConfig::DEFAULT_PACK_FORMAT,
|
PackConfig::DEFAULT_PACK_FORMAT,
|
||||||
&program_paths,
|
&program_paths,
|
||||||
|
|
13
src/util.rs
13
src/util.rs
|
@ -5,8 +5,6 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use camino::Utf8PathBuf;
|
|
||||||
|
|
||||||
use inquire::{autocompletion::Replacement, Autocomplete};
|
use inquire::{autocompletion::Replacement, Autocomplete};
|
||||||
use path_absolutize::Absolutize;
|
use path_absolutize::Absolutize;
|
||||||
|
|
||||||
|
@ -68,17 +66,20 @@ impl PathAutocomplete {
|
||||||
if !self.cache.contains_key(parent) {
|
if !self.cache.contains_key(parent) {
|
||||||
tracing::trace!("Cache miss for \"{}\", reading dir", parent);
|
tracing::trace!("Cache miss for \"{}\", reading dir", parent);
|
||||||
|
|
||||||
let parent_path = Utf8PathBuf::from(parent);
|
let parent_path = PathBuf::from(parent);
|
||||||
if !parent_path.exists() || !parent_path.is_dir() {
|
if !parent_path.exists() || !parent_path.is_dir() {
|
||||||
return Err("Path does not exist");
|
return Err("Path does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
let entries = parent_path
|
let entries = parent_path
|
||||||
.read_dir_utf8()
|
.read_dir()
|
||||||
.map_err(|_| "Could not read dir")?
|
.map_err(|_| "Could not read dir")?
|
||||||
.filter_map(|entry| {
|
.filter_map(|entry| {
|
||||||
entry.ok().map(|entry| {
|
entry.ok().and_then(|entry| {
|
||||||
entry.file_name().to_string() + if entry.path().is_dir() { "/" } else { "" }
|
Some(
|
||||||
|
entry.file_name().into_string().ok()?.to_string()
|
||||||
|
+ if entry.path().is_dir() { "/" } else { "" },
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
Loading…
Reference in New Issue