From 9e7c0fd45e169929156bdb317b10d7bb3db65f8b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 7 Mar 2026 19:37:52 +0800 Subject: Add callback support to chunk_stream_with and implement stream writing --- src/entry.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/entry.rs (limited to 'src/entry.rs') diff --git a/src/entry.rs b/src/entry.rs new file mode 100644 index 0000000..4e91e59 --- /dev/null +++ b/src/entry.rs @@ -0,0 +1,50 @@ +use std::process::exit; + +use crate::chunker::{ + context::ButckContext, + rw::{self, error::ButckRWError}, +}; + +pub async fn entry(ctx: ButckContext, args: Vec) -> 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" => { + let policies = butck_policies::policies(); + let stream_policies = butck_policies::stream_policies(); + let mut all_policies: Vec<_> = + policies.iter().chain(stream_policies.iter()).collect(); + all_policies.sort(); + all_policies.dedup(); + all_policies.iter().for_each(|p| println!("{}", p)); + return Ok(()); + } + "simple_policies" => { + butck_policies::policies() + .iter() + .for_each(|p| println!("{}", p)); + return Ok(()); + } + "stream_policies" => { + butck_policies::stream_policies() + .iter() + .for_each(|p| println!("{}", 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()); +} -- cgit