summaryrefslogtreecommitdiff
path: root/src/chunker/entry.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-04 21:26:04 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-04 21:35:09 +0800
commit22926ce29e3f8e040ec349401aeb6a77f32eae72 (patch)
tree678753ec49a61fb9d3e2d8e869393dec90ea7ef4 /src/chunker/entry.rs
Initialize Butchunker project structure and policy system
Diffstat (limited to 'src/chunker/entry.rs')
-rw-r--r--src/chunker/entry.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/chunker/entry.rs b/src/chunker/entry.rs
new file mode 100644
index 0000000..4fdb1f8
--- /dev/null
+++ b/src/chunker/entry.rs
@@ -0,0 +1,39 @@
+use std::process::exit;
+
+use log::info;
+
+use crate::chunker::{
+ context::ButckContext,
+ rw::{self, error::ButckRWError},
+};
+
+pub async fn entry(ctx: ButckContext, args: Vec<String>) -> Result<(), ButckRWError> {
+ if let Some(subcommand) = args.first() {
+ return match subcommand.as_str() {
+ "write" => rw::storage::write(ctx).await,
+ "build" => rw::storage::build(ctx).await,
+ "policies" => {
+ butck_policies::policies()
+ .iter()
+ .for_each(|p| info!("{}", p));
+ return Ok(());
+ }
+ _ => {
+ print_help();
+ exit(1)
+ }
+ };
+ }
+ Ok(())
+}
+
+pub fn print_help() {
+ println!("{}", include_str!("../../resources/helps/butck.txt").trim());
+}
+
+pub fn print_version() {
+ println!(
+ "{}",
+ include_str!("../../resources/version_info.txt").trim()
+ );
+}