Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
9ae87f23
提交
9ae87f23
authored
4月 04, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get build opts from toml
上级
0859adaf
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
40 行增加
和
13 行删除
+40
-13
Cargo.lock
roboplc-cli/Cargo.lock
+1
-1
Cargo.toml
roboplc-cli/Cargo.toml
+1
-1
main.rs
roboplc-cli/src/main.rs
+38
-11
没有找到文件。
roboplc-cli/Cargo.lock
浏览文件 @
9ae87f23
...
...
@@ -1030,7 +1030,7 @@ dependencies = [
[[package]]
name = "roboplc-cli"
version = "0.1.
1
"
version = "0.1.
2
"
dependencies = [
"clap",
"colored",
...
...
roboplc-cli/Cargo.toml
浏览文件 @
9ae87f23
[package]
name
=
"roboplc-cli"
version
=
"0.1.
2
"
version
=
"0.1.
3
"
edition
=
"2021"
authors
=
[
"Serhij S. <div@altertech.com>"
]
license
=
"Apache-2.0"
...
...
roboplc-cli/src/main.rs
浏览文件 @
9ae87f23
...
...
@@ -218,25 +218,50 @@ fn flash(
key
:
&
str
,
agent
:
Agent
,
opts
:
FlashCommand
,
robo_toml
:
Option
<
toml
::
Value
>
,
)
->
Result
<
(),
Box
<
dyn
std
::
error
::
Error
>>
{
if
let
Some
(
file
)
=
opts
.file
{
flash_file
(
url
,
key
,
agent
,
file
,
opts
.force
,
opts
.run
)
?
;
}
else
{
let
cargo_target
=
if
let
Some
(
cargo_target
)
=
opts
.cargo_target
{
cargo_target
}
else
{
let
mut
cargo_target
:
Option
<
String
>
=
None
;
if
let
Some
(
c
)
=
opts
.cargo_target
{
cargo_target
.replace
(
c
);
}
if
cargo_target
.is_none
()
{
if
let
Some
(
ref
value
)
=
robo_toml
{
cargo_target
=
value
.get
(
"build"
)
.and_then
(|
v
|
v
.get
(
"target"
))
.map
(|
v
|
v
.as_str
()
.unwrap
()
.to_owned
());
}
}
if
cargo_target
.is_none
()
{
let
resp
=
agent
.post
(
&
format!
(
"{}{}/query.info.kernel"
,
url
,
API_PREFIX
))
.set
(
"x-auth-key"
,
key
)
.call
()
?
;
let
info
:
KernelInfo
=
resp
.into_json
()
?
;
format!
(
"{}-unknown-linux-gnu"
,
info
.machine
)
};
let
cargo
=
opts
.cargo
.unwrap_or_else
(||
which
(
"cross"
)
.unwrap_or_else
(|
_
|
Path
::
new
(
"cargo"
)
.to_owned
()));
cargo_target
.replace
(
format!
(
"{}-unknown-linux-gnu"
,
info
.machine
));
}
let
mut
cargo
:
Option
<
PathBuf
>
=
None
;
if
let
Some
(
c
)
=
opts
.cargo
{
cargo
.replace
(
c
);
}
if
cargo
.is_none
()
{
if
let
Some
(
ref
value
)
=
robo_toml
{
cargo
=
value
.get
(
"build"
)
.and_then
(|
v
|
v
.get
(
"cargo"
))
.map
(|
v
|
v
.as_str
()
.unwrap
()
.into
());
}
}
if
cargo
.is_none
()
{
cargo
=
which
(
"cross"
)
.ok
();
}
let
cargo_target
=
cargo_target
.unwrap
();
let
cargo
=
cargo
.unwrap_or_else
(||
"cargo"
.into
());
let
Some
(
name
)
=
find_name_and_chdir
()
else
{
return
Err
(
"Could not find C
ross
.toml/binary name"
.into
());
return
Err
(
"Could not find C
argo
.toml/binary name"
.into
());
};
let
binary_name
=
Path
::
new
(
"target"
)
.join
(
&
cargo_target
)
...
...
@@ -305,6 +330,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let
mut
url
=
args
.url
;
let
mut
key
=
args
.key
;
let
mut
timeout
=
args
.timeout
;
let
mut
robo_toml
:
Option
<
toml
::
Value
>
=
None
;
if
let
Some
(
roboplc_toml_path
)
=
find_roboplc_toml
()
{
let
contents
=
fs
::
read_to_string
(
roboplc_toml_path
)
?
;
let
value
=
contents
.parse
::
<
toml
::
Value
>
()
?
;
...
...
@@ -327,10 +353,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
value
.get
(
"remote"
)
.and_then
(|
v
|
v
.get
(
"timeout"
))
.and_then
(
|
v
|
v
.as_integer
()
)
.and_then
(
toml
::
Value
::
as_integer
)
.ok_or
(
"Invalid timeout (must be integer)"
)
?
,
)
?
);
}
robo_toml
.replace
(
value
);
}
let
timeout
=
timeout
.unwrap_or
(
DEFAULT_TIMEOUT
);
let
url
=
url
.ok_or
(
"URL not specified"
)
?
;
...
...
@@ -350,7 +377,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
set_mode_command
(
&
url
,
&
key
,
agent
,
Mode
::
Run
)
?
;
}
SubCommand
::
Flash
(
opts
)
=>
{
flash
(
&
url
,
&
key
,
agent
,
opts
)
?
;
flash
(
&
url
,
&
key
,
agent
,
opts
,
robo_toml
)
?
;
}
SubCommand
::
Purge
=>
{
purge_command
(
&
url
,
&
key
,
agent
)
?
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论