Skip to main content

mcumgr_toolkit/commands/
shell.rs

1use serde::{Deserialize, Serialize};
2
3/// [Shell command line execute](https://docs.zephyrproject.org/latest/services/device_mgmt/smp_groups/smp_group_9.html#shell-command-line-execute) command
4#[derive(Debug, Serialize)]
5pub struct ShellCommandLineExecute<'a> {
6    /// array consisting of strings representing command and its arguments
7    pub argv: &'a [String],
8}
9
10/// Response for [`ShellCommandLineExecute`] command
11#[derive(Debug, Deserialize, Eq, PartialEq)]
12pub struct ShellCommandLineExecuteResponse {
13    /// command output
14    pub o: String,
15    /// return code from shell command execution
16    pub ret: i32,
17}
18
19#[cfg(test)]
20mod tests {
21    use super::super::macros::command_encode_decode_test;
22    use super::*;
23    use ciborium::cbor;
24
25    command_encode_decode_test! {
26        shell,
27        (2, 9, 0),
28        ShellCommandLineExecute{
29            argv: &[
30                "kernel".to_string(),
31                "version".to_string(),
32            ],
33        },
34        cbor!({
35            "argv" => ["kernel", "version"]
36        }),
37        cbor!({
38            "o" => "some_zephyr_version",
39            "ret" => -4
40        }),
41        ShellCommandLineExecuteResponse{
42            o: "some_zephyr_version".to_string(),
43            ret: -4,
44        },
45    }
46}