Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
f5614f87
提交
f5614f87
authored
10月 05, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pro live update
上级
8b3c047e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
10 行删除
+27
-10
arguments.rs
roboplc-cli/src/arguments.rs
+5
-0
flashing.rs
roboplc-cli/src/flashing.rs
+22
-10
没有找到文件。
roboplc-cli/src/arguments.rs
浏览文件 @
f5614f87
...
@@ -140,6 +140,8 @@ pub struct FlashCommand {
...
@@ -140,6 +140,8 @@ pub struct FlashCommand {
help
=
"Put remote in RUN mode after flashing, for Docker: run the container"
help
=
"Put remote in RUN mode after flashing, for Docker: run the container"
)]
)]
pub
run
:
bool
,
pub
run
:
bool
,
#[clap(long,
help
=
"Perform live update (requires RoboPLC Pro)"
)]
pub
live
:
bool
,
}
}
#[derive(Parser)]
#[derive(Parser)]
...
@@ -179,6 +181,7 @@ pub struct FlashExec {
...
@@ -179,6 +181,7 @@ pub struct FlashExec {
pub
file
:
Option
<
PathBuf
>
,
pub
file
:
Option
<
PathBuf
>
,
pub
force
:
bool
,
pub
force
:
bool
,
pub
run
:
bool
,
pub
run
:
bool
,
pub
live
:
bool
,
pub
program_args
:
Vec
<
String
>
,
pub
program_args
:
Vec
<
String
>
,
pub
program_env
:
BTreeMap
<
String
,
String
>
,
pub
program_env
:
BTreeMap
<
String
,
String
>
,
}
}
...
@@ -192,6 +195,7 @@ impl From<FlashCommand> for FlashExec {
...
@@ -192,6 +195,7 @@ impl From<FlashCommand> for FlashExec {
file
:
cmd
.file
,
file
:
cmd
.file
,
force
:
cmd
.force
,
force
:
cmd
.force
,
run
:
cmd
.run
,
run
:
cmd
.run
,
live
:
cmd
.live
,
program_args
:
Vec
::
new
(),
program_args
:
Vec
::
new
(),
program_env
:
BTreeMap
::
new
(),
program_env
:
BTreeMap
::
new
(),
}
}
...
@@ -220,6 +224,7 @@ impl From<ExecCommand> for FlashExec {
...
@@ -220,6 +224,7 @@ impl From<ExecCommand> for FlashExec {
file
:
cmd
.file
,
file
:
cmd
.file
,
force
:
cmd
.force
,
force
:
cmd
.force
,
run
:
false
,
run
:
false
,
live
:
false
,
program_args
:
cmd
.args
,
program_args
:
cmd
.args
,
program_env
,
program_env
,
}
}
...
...
roboplc-cli/src/flashing.rs
浏览文件 @
f5614f87
...
@@ -5,7 +5,7 @@ use std::{
...
@@ -5,7 +5,7 @@ use std::{
};
};
use
colored
::
Colorize
as
_
;
use
colored
::
Colorize
as
_
;
use
serde
_json
::
json
;
use
serde
::
Serialize
;
use
ureq
::
Agent
;
use
ureq
::
Agent
;
use
ureq_multipart
::
MultipartBuilder
;
use
ureq_multipart
::
MultipartBuilder
;
use
which
::
which
;
use
which
::
which
;
...
@@ -18,7 +18,7 @@ use crate::{
...
@@ -18,7 +18,7 @@ use crate::{
API_PREFIX
,
API_PREFIX
,
};
};
#[allow(clippy
::
too_many_arguments)]
#[allow(clippy
::
too_many_arguments
,
clippy
::
fn_params_excessive_bools
)]
fn
flash_file
(
fn
flash_file
(
url
:
&
str
,
url
:
&
str
,
key
:
&
str
,
key
:
&
str
,
...
@@ -26,6 +26,7 @@ fn flash_file(
...
@@ -26,6 +26,7 @@ fn flash_file(
file
:
&
Path
,
file
:
&
Path
,
force
:
bool
,
force
:
bool
,
run
:
bool
,
run
:
bool
,
live
:
bool
,
exec_only
:
bool
,
exec_only
:
bool
,
program_args
:
Vec
<
String
>
,
program_args
:
Vec
<
String
>
,
program_env
:
BTreeMap
<
String
,
String
>
,
program_env
:
BTreeMap
<
String
,
String
>
,
...
@@ -37,6 +38,9 @@ fn flash_file(
...
@@ -37,6 +38,9 @@ fn flash_file(
return
crate
::
exec
::
exec
(
url
,
key
,
file
,
force
,
program_args
,
program_env
);
return
crate
::
exec
::
exec
(
url
,
key
,
file
,
force
,
program_args
,
program_env
);
}
}
if
let
Some
(
docker_img
)
=
url
.strip_prefix
(
"docker://"
)
{
if
let
Some
(
docker_img
)
=
url
.strip_prefix
(
"docker://"
)
{
if
run
{
return
Err
(
"Live update for Docker images is not supported"
.into
());
}
let
tag
=
std
::
env
::
var
(
"ROBOPLC_DOCKER_TAG"
)
.unwrap_or_else
(|
_
|
{
let
tag
=
std
::
env
::
var
(
"ROBOPLC_DOCKER_TAG"
)
.unwrap_or_else
(|
_
|
{
crate
::
TARGET_PACKAGE_VERSION
crate
::
TARGET_PACKAGE_VERSION
.get
()
.get
()
...
@@ -81,17 +85,20 @@ fn flash_file(
...
@@ -81,17 +85,20 @@ fn flash_file(
}
}
}
}
}
else
{
}
else
{
#[derive(Serialize)]
struct
Payload
{
#[serde(skip_serializing_if
=
"std::ops::Not::not"
)]
force
:
bool
,
#[serde(skip_serializing_if
=
"std::ops::Not::not"
)]
run
:
bool
,
#[serde(skip_serializing_if
=
"std::ops::Not::not"
)]
live
:
bool
,
}
let
(
content_type
,
data
)
=
MultipartBuilder
::
new
()
let
(
content_type
,
data
)
=
MultipartBuilder
::
new
()
.add_file
(
"file"
,
file
)
?
.add_file
(
"file"
,
file
)
?
.add_text
(
.add_text
(
"params"
,
"params"
,
&
serde_json
::
to_string
(
&
json!
{
&
serde_json
::
to_string
(
&
Payload
{
force
,
run
,
live
})
?
,
{
"force"
:
force
,
"run"
:
run
,
}
})
?
,
)
?
)
?
.finish
()
?
;
.finish
()
?
;
agent
agent
...
@@ -104,13 +111,14 @@ fn flash_file(
...
@@ -104,13 +111,14 @@ fn flash_file(
Ok
(())
Ok
(())
}
}
#[allow(clippy
::
too_many_arguments)]
#[allow(clippy
::
too_many_arguments
,
clippy
::
fn_params_excessive_bools
)]
fn
run_build_custom
(
fn
run_build_custom
(
url
:
&
str
,
url
:
&
str
,
key
:
&
str
,
key
:
&
str
,
agent
:
Agent
,
agent
:
Agent
,
force
:
bool
,
force
:
bool
,
run
:
bool
,
run
:
bool
,
live
:
bool
,
cmd
:
&
str
,
cmd
:
&
str
,
file
:
&
Path
,
file
:
&
Path
,
exec_only
:
bool
,
exec_only
:
bool
,
...
@@ -138,6 +146,7 @@ fn run_build_custom(
...
@@ -138,6 +146,7 @@ fn run_build_custom(
file
,
file
,
force
,
force
,
run
,
run
,
live
,
exec_only
,
exec_only
,
program_args
,
program_args
,
program_env
,
program_env
,
...
@@ -163,6 +172,7 @@ pub fn flash(
...
@@ -163,6 +172,7 @@ pub fn flash(
&
file
,
&
file
,
opts
.force
,
opts
.force
,
opts
.run
,
opts
.run
,
opts
.live
,
exec_only
,
exec_only
,
opts
.program_args
,
opts
.program_args
,
opts
.program_env
,
opts
.program_env
,
...
@@ -174,6 +184,7 @@ pub fn flash(
...
@@ -174,6 +184,7 @@ pub fn flash(
agent
,
agent
,
opts
.force
,
opts
.force
,
opts
.run
,
opts
.run
,
opts
.live
,
&
custom_cmd
,
&
custom_cmd
,
&
build_custom
&
build_custom
.file
.file
...
@@ -253,6 +264,7 @@ pub fn flash(
...
@@ -253,6 +264,7 @@ pub fn flash(
&
binary_name
,
&
binary_name
,
opts
.force
,
opts
.force
,
opts
.run
,
opts
.run
,
opts
.live
,
exec_only
,
exec_only
,
opts
.program_args
,
opts
.program_args
,
opts
.program_env
,
opts
.program_env
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论