diff --git a/src/cli.rs b/src/cli.rs index f1c30ae..ff4bbd3 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -19,6 +19,7 @@ pub enum CliSub { Db(SaDbCli), } +/// ConvertCli 用于将指定的 cvrf 格式 xml 文件转换为 cusa 格式 #[derive(Clone, Debug, Parser)] #[command(author, version, about, long_about = None)] pub struct ConvertCli { @@ -36,6 +37,16 @@ pub struct ConvertCli { pub print: bool, } +impl ConvertCli { + pub fn new(input: String, output: Option, print: bool) -> Self { + ConvertCli { + input, + output, + print, + } + } +} + #[derive(Clone, Debug, Parser)] #[command(author, version, about, long_about = None)] pub struct SaDbCli { diff --git a/src/lib.rs b/src/lib.rs index ac2a3c4..58cfc97 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,24 @@ pub fn cumain() -> Result<()> { } } +/// 可使用 convert 函数将 cvrf 格式文件转换并输出至指定的 cusa 文件。 +/// +/// 例: +/// +/// ```no_run +/// use cvrf2cusa::cli::ConvertCli +/// +/// let cli = ConvertCli::new( +/// // input +/// "xxx-cvrf.xml".to_string, +/// // output +/// Some("pkg_version_said.json".to_string), +/// // print to screen +/// false, +/// ); +/// +/// cvrf2cusa::Convert(cli)?; +/// ``` pub fn covert(cli: &cli::ConvertCli) -> Result<()> { // 检查 input,此为必须项 let input = Path::new(&cli.input);