diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-07 19:37:52 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-07 19:37:52 +0800 |
| commit | 9e7c0fd45e169929156bdb317b10d7bb3db65f8b (patch) | |
| tree | 94c1e0e6cafe996b7b7da8dfd6e1ff1a04539cda /src/entry.rs | |
| parent | 22926ce29e3f8e040ec349401aeb6a77f32eae72 (diff) | |
Add callback support to chunk_stream_with and implement stream writing
Diffstat (limited to 'src/entry.rs')
| -rw-r--r-- | src/entry.rs | 50 |
1 files changed, 50 insertions, 0 deletions
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<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" => { + 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()); +} |
