world_count/lib.rs
1pub mod batch; // 批处理
2pub mod stream; // 流处理
3
4pub use aoko::no_std::algebraic::sum::TimeUnit;
5use clap::Parser;
6
7/// Batch and stream processing word-count, support English & Chinese.
8#[derive(Parser)]
9#[clap(version = "0.1.4", author = "hzqd <hzqelf@yeah.net>")]
10pub struct Args {
11 /// Specify the dictionary name, no dictionary by default
12 #[clap(short, long, default_value = "")]
13 pub dictionary: String,
14
15 /// Specify the time unit, support nanos, micros, millis, secs
16 #[clap(short, long, default_value = "millis")]
17 pub time: TimeUnit,
18
19 /// Set Mode, support batch and stream processing
20 #[clap(subcommand)]
21 pub subcmd: Mode,
22}
23
24#[derive(Parser)]
25pub enum Mode {
26 /// A subcommand for specify the batch processing
27 #[allow(non_camel_case_types)]
28 batch {
29 /// Specify the input file name
30 #[clap(short, long)]
31 input: String,
32
33 /// Specify the output file name
34 #[clap(short, long)]
35 output: String,
36
37 /// With -e to select English or Chinese otherwise
38 #[clap(short, long)]
39 en_or_cn: bool,
40 },
41 /// Not implemented — Will be implemented in the next version ; A subcommand for specify the stream processing
42 #[allow(non_camel_case_types)]
43 stream {
44 /// Ip address and port, e.g. 127.0.0.1:8080
45 #[clap(short, long)]
46 ip: String,
47
48 /// With -e to select English or Chinese otherwise
49 #[clap(short, long)]
50 en_or_cn: bool,
51 }
52}
53
54pub fn get_args() -> Args {
55 Args::parse()
56}