11use crate :: { XmakeCommand , XmakeCommandType , XmakeError , XmakeOutput , XmakeWrapper } ;
22
3- /// xmake命令构建器
3+ /// xmake command builder
44#[ derive( Debug , Clone ) ]
55pub struct XmakeCommandBuilder {
66 wrapper : XmakeWrapper ,
77 pub ( crate ) command : XmakeCommand ,
88}
99
1010impl XmakeCommandBuilder {
11- /// 创建新的命令构建器
11+ /// Create a new command builder
1212 pub fn new ( wrapper : XmakeWrapper ) -> Self {
1313 Self {
1414 wrapper,
15- command : XmakeCommand :: new ( XmakeCommandType :: Build ) , // 默认命令
15+ command : XmakeCommand :: new ( XmakeCommandType :: Build ) , // default command
1616 }
1717 }
1818
19- /// 设置命令类型
19+ /// Set command type
2020 pub fn command_type ( mut self , cmd_type : XmakeCommandType ) -> Self {
2121 self . command . command_type = cmd_type;
2222 self
2323 }
2424
25- /// 添加参数
25+ /// Add an argument
2626 pub fn arg < S : Into < String > > ( mut self , arg : S ) -> Self {
2727 self . command = self . command . arg ( arg) ;
2828 self
2929 }
3030
31- /// 添加多个参数
31+ /// Add multiple arguments
3232 pub fn args < I , S > ( mut self , args : I ) -> Self
3333 where
3434 I : IntoIterator < Item = S > ,
@@ -38,7 +38,7 @@ impl XmakeCommandBuilder {
3838 self
3939 }
4040
41- /// 添加环境变量
41+ /// Add an environment variable
4242 pub fn env < K , V > ( mut self , key : K , value : V ) -> Self
4343 where
4444 K : Into < String > ,
@@ -48,73 +48,73 @@ impl XmakeCommandBuilder {
4848 self
4949 }
5050
51- /// 设置是否继承父进程环境变量
51+ /// Set whether to inherit parent environment variables
5252 pub fn inherit_env ( mut self , inherit : bool ) -> Self {
5353 self . command = self . command . inherit_env ( inherit) ;
5454 self
5555 }
5656
57- /// 执行命令
57+ /// Execute the command
5858 pub async fn execute ( self ) -> Result < XmakeOutput , XmakeError > {
5959 self . wrapper . execute ( & self . command ) . await
6060 }
6161
62- /// 构建项目
62+ /// Build project
6363 pub fn build ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
6464 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Build )
6565 }
6666
67- /// 清理项目
67+ /// Clean project
6868 pub fn clean ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
6969 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Clean )
7070 }
7171
72- /// 配置项目
72+ /// Configure project
7373 pub fn config ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
7474 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Config )
7575 }
7676
77- /// 安装项目
77+ /// Install project
7878 pub fn install ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
7979 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Install )
8080 }
8181
82- /// 创建新项目
82+ /// Create new project
8383 pub fn create ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
8484 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Create )
8585 }
8686
87- /// 运行项目
87+ /// Run project
8888 pub fn run ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
8989 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Run )
9090 }
9191
92- /// 显示版本信息
92+ /// Show version info
9393 pub fn version ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
9494 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Version )
9595 }
9696
97- /// 显示帮助信息
97+ /// Show help info
9898 pub fn help ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
9999 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Help )
100100 }
101101
102- /// 显示项目信息
102+ /// Show project info
103103 pub fn show ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
104104 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Show )
105105 }
106106
107- /// 包管理命令
107+ /// Package management command
108108 pub fn package ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
109109 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Package )
110110 }
111111
112- /// 测试项目
112+ /// Test project
113113 pub fn test ( ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
114114 |wrapper| XmakeCommandBuilder :: new ( wrapper) . command_type ( XmakeCommandType :: Test )
115115 }
116116
117- /// 自定义命令
117+ /// Custom command
118118 pub fn custom < S : Into < String > > ( cmd : S ) -> impl Fn ( XmakeWrapper ) -> XmakeCommandBuilder {
119119 let cmd = cmd. into ( ) ;
120120 move |wrapper| {
@@ -123,64 +123,64 @@ impl XmakeCommandBuilder {
123123 }
124124}
125125
126- /// 便捷的命令构建函数
126+ /// Convenience command builder helpers
127127impl XmakeWrapper {
128- /// 构建项目
128+ /// Build project
129129 pub fn build ( & self ) -> XmakeCommandBuilder {
130130 XmakeCommandBuilder :: build ( ) ( self . clone ( ) )
131131 }
132132
133- /// 清理项目
133+ /// Clean project
134134 pub fn clean ( & self ) -> XmakeCommandBuilder {
135135 XmakeCommandBuilder :: clean ( ) ( self . clone ( ) )
136136 }
137137
138- /// 配置项目
138+ /// Configure project
139139 pub fn config ( & self ) -> XmakeCommandBuilder {
140140 XmakeCommandBuilder :: config ( ) ( self . clone ( ) )
141141 }
142142
143- /// 安装项目
143+ /// Install project
144144 pub fn install ( & self ) -> XmakeCommandBuilder {
145145 XmakeCommandBuilder :: install ( ) ( self . clone ( ) )
146146 }
147147
148- /// 创建新项目
148+ /// Create new project
149149 pub fn create ( & self ) -> XmakeCommandBuilder {
150150 XmakeCommandBuilder :: create ( ) ( self . clone ( ) )
151151 }
152152
153- /// 运行项目
153+ /// Run project
154154 pub fn run ( & self ) -> XmakeCommandBuilder {
155155 XmakeCommandBuilder :: run ( ) ( self . clone ( ) )
156156 }
157157
158- /// 显示版本信息
158+ /// Show version info
159159 pub fn version ( & self ) -> XmakeCommandBuilder {
160160 XmakeCommandBuilder :: version ( ) ( self . clone ( ) )
161161 }
162162
163- /// 显示帮助信息
163+ /// Show help info
164164 pub fn help ( & self ) -> XmakeCommandBuilder {
165165 XmakeCommandBuilder :: help ( ) ( self . clone ( ) )
166166 }
167167
168- /// 显示项目信息
168+ /// Show project info
169169 pub fn show ( & self ) -> XmakeCommandBuilder {
170170 XmakeCommandBuilder :: show ( ) ( self . clone ( ) )
171171 }
172172
173- /// 包管理命令
173+ /// Package management command
174174 pub fn package ( & self ) -> XmakeCommandBuilder {
175175 XmakeCommandBuilder :: package ( ) ( self . clone ( ) )
176176 }
177177
178- /// 测试项目
178+ /// Test project
179179 pub fn test ( & self ) -> XmakeCommandBuilder {
180180 XmakeCommandBuilder :: test ( ) ( self . clone ( ) )
181181 }
182182
183- /// 自定义命令
183+ /// Custom command
184184 pub fn custom < S : Into < String > > ( & self , cmd : S ) -> XmakeCommandBuilder {
185185 XmakeCommandBuilder :: custom ( cmd) ( self . clone ( ) )
186186 }
0 commit comments