xref: /DragonOS/tools/debugging/logmonitor/src/command.rs (revision 1a72a751b18cf5bbe7b5b9e91aff530de0c18501)
1 use std::path::PathBuf;
2 
3 use clap::Parser;
4 
5 #[derive(Debug, Parser, Clone)]
6 pub struct CommandLineArgs {
7     #[arg(short, long)]
8     /// The kernel ELF file to load.
9     pub kernel: PathBuf,
10 
11     /// The kernel memory file to load.
12     #[arg(long, value_parser=kmem_file_parser, default_value = "/dev/shm/dragonos-qemu-shm.ram")]
13     pub kmem: String,
14 
15     /// If set, the monitor will start the TUI.
16     #[arg(long, default_value = "false")]
17     pub tui: bool,
18 
19     /// The directory to store the log files.
20     #[arg(long, default_value = "logs")]
21     pub log_dir: PathBuf,
22 }
23 
24 /// 用于解析kmem参数的函数
25 fn kmem_file_parser(s: &str) -> Result<String, String> {
26     log::warn!("kmem_file_parser: {}", s);
27     if s.len() == 0 {
28         return Ok("/dev/shm/dragonos-qemu-shm.ram".to_string());
29     } else {
30         return Ok(s.to_string());
31     }
32 }
33