✨➕♻️💩 cli, vanth, Cargo.toml, Cargo.lock: Add CLI framework and refactor vanth crate structure
- Added a new `vanth_cli` crate with `clap` command structure for `vanth fs open/save` commands. - Removed `main.rs` from `vanth` crate as it is now a library without a binary target. - Added `fs.rs` module and new structs `HashedValue`, `Value`, `Ty` with `Vanth` trait to support serialization. - Updated `Cargo.toml` to include `clap` as a workspace dependency and added `vanth_cli` as a new crate. - Added multiple dependencies (`anstream`, `anstyle`, `clap`, `heck`, etc.) in `Cargo.lock` to support the CLI. - Created placeholder test files `tests/fs/mod.rs` and `tests/main.rs` in `vanth` crate for future use. - Marked CLI command implementations with TODOs as functionality is not yet implemented.
This commit is contained in:
parent
45a68865b6
commit
8b76fcb659
10 changed files with 218 additions and 15 deletions
134
Cargo.lock
generated
134
Cargo.lock
generated
|
@ -2,6 +2,56 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.9"
|
||||
|
@ -300,6 +350,52 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
||||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "2.5.0"
|
||||
|
@ -521,6 +617,12 @@ dependencies = [
|
|||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.10.0"
|
||||
|
@ -531,6 +633,12 @@ dependencies = [
|
|||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
|
@ -599,6 +707,12 @@ version = "1.21.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
|
||||
|
||||
[[package]]
|
||||
name = "parking"
|
||||
version = "2.2.1"
|
||||
|
@ -774,6 +888,12 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.6.1"
|
||||
|
@ -861,6 +981,12 @@ version = "0.2.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.17.0"
|
||||
|
@ -885,6 +1011,14 @@ dependencies = [
|
|||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vanth_cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"vanth",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "variadics_please"
|
||||
version = "1.1.0"
|
||||
|
|
|
@ -7,6 +7,7 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[workspace.dependencies]
|
||||
clap = { version = "4.5.42", features = ["derive"] }
|
||||
bevy_app = "0.16.1"
|
||||
bevy_ecs = "0.16.1"
|
||||
bitcode = "0.6.6"
|
||||
|
|
8
crates/cli/Cargo.toml
Normal file
8
crates/cli/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "vanth_cli"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
clap.workspace = true
|
||||
vanth = { path = "../vanth" }
|
47
crates/cli/src/cli.rs
Normal file
47
crates/cli/src/cli.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "vanth")]
|
||||
#[command(about = "Vanth CLI tool")]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum Commands {
|
||||
#[command(about = "File system operations")]
|
||||
Fs {
|
||||
#[command(subcommand)]
|
||||
command: FsCommands,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum FsCommands {
|
||||
#[command(about = "Read from path and print JSON to stdout")]
|
||||
Open {
|
||||
#[arg(help = "Path to read from")]
|
||||
path: String,
|
||||
},
|
||||
#[command(about = "Take JSON from stdin and write to path")]
|
||||
Save {
|
||||
#[arg(help = "Path to write to")]
|
||||
path: String,
|
||||
},
|
||||
}
|
||||
|
||||
pub fn execute(cli: Cli) {
|
||||
match cli.command {
|
||||
Commands::Fs { command } => match command {
|
||||
FsCommands::Open { path } => {
|
||||
// TODO: implement fs open functionality
|
||||
println!("fs open: {}", path);
|
||||
}
|
||||
FsCommands::Save { path } => {
|
||||
// TODO: implement fs save functionality
|
||||
println!("fs save: {}", path);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
10
crates/cli/src/main.rs
Normal file
10
crates/cli/src/main.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use clap::Parser;
|
||||
|
||||
mod cli;
|
||||
|
||||
use cli::Cli;
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
cli::execute(cli);
|
||||
}
|
0
crates/vanth/src/fs.rs
Normal file
0
crates/vanth/src/fs.rs
Normal file
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
/// Library crate for the `vanth` ECS-based database node.
|
||||
use bevy_app::{App, Plugin};
|
||||
use bevy_ecs::{prelude::*, query::QueryData};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
|
||||
use crate::entity::EntityId;
|
||||
|
||||
|
@ -54,16 +54,25 @@ impl Node {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Component, Serialize)]
|
||||
pub struct Vanth<T: VanthTuple + QueryData> {
|
||||
id: crate::entity::Id<Self>,
|
||||
_marker: PhantomData<T>,
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct HashedValue {
|
||||
content_hash: ContentHash,
|
||||
inner: Value
|
||||
}
|
||||
|
||||
impl <T: VanthTuple + QueryData> Vanth<T> {
|
||||
fn save_system(query: Query<T>) {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Value {
|
||||
ty: Ty,
|
||||
data: Vec<u8>,
|
||||
}
|
||||
|
||||
}
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Ty {
|
||||
path: Vec<String>,
|
||||
}
|
||||
|
||||
pub trait Vanth: Serialize + DeserializeOwned {
|
||||
fn ty() -> Ty;
|
||||
}
|
||||
|
||||
// TODO: Impl for different tuple sizes
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
mod util;
|
||||
mod vanth;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
0
crates/vanth/tests/fs/mod.rs
Normal file
0
crates/vanth/tests/fs/mod.rs
Normal file
0
crates/vanth/tests/main.rs
Normal file
0
crates/vanth/tests/main.rs
Normal file
Loading…
Add table
Add a link
Reference in a new issue