diff options
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/butck.rs | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/bin/butck.rs b/src/bin/butck.rs index 1152bc8..996ee68 100644 --- a/src/bin/butck.rs +++ b/src/bin/butck.rs @@ -1,12 +1,9 @@ use std::process::exit; use butchunker::{ - chunker::{ - context::ButckContext, - rw::error::{ButckRWError, ButckRWErrorKind}, - }, - entry::{entry, print_help, print_version}, + ctx::ButckContext, special_argument, special_flag, + storage::{ButckRWError, ButckRWErrorKind, build, write}, utils::log::init_logger, }; use just_progress::{progress, renderer}; @@ -116,3 +113,50 @@ fn handle_entry_result(r: Result<(), ButckRWError>) { }, } } + +pub async fn entry(ctx: ButckContext, args: Vec<String>) -> Result<(), ButckRWError> { + if let Some(subcommand) = args.first() { + return match subcommand.as_str() { + "write" => write(ctx).await, + "build" => build(ctx).await, + "lspolicy" => { + if ctx.stream_read.is_some() { + butck_policies::stream_policies() + .iter() + .for_each(|p| println!("{}", p)); + } else { + butck_policies::policies() + .iter() + .for_each(|p| println!("{}", p)); + } + return Ok(()); + } + "lspolicy-all" => { + 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(()); + } + _ => { + 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() + ); +} |
