♻️💩 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:
Markus Scully 2025-08-04 21:36:25 +03:00
parent 45a68865b6
commit 8b76fcb659
Signed by: mascully
GPG key ID: 93CA5814B698101C
10 changed files with 218 additions and 15 deletions

8
crates/cli/Cargo.toml Normal file
View 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
View 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
View 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
View file

View 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

View file

@ -1,6 +0,0 @@
mod util;
mod vanth;
fn main() {
println!("Hello, world!");
}

View file

View file