command_parser: fix pid

This commit is contained in:
Astro 2019-09-19 00:59:16 +02:00
parent f64e4fe2f3
commit 6d4676a72a
1 changed files with 12 additions and 11 deletions

View File

@ -193,6 +193,7 @@ fn pwm(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
))(input)
}
/// `pid <parameter> <value>`
fn pid_parameter(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
let (input, parameter) =
alt((value(PidParameter::Target, tag("target")),
@ -212,18 +213,18 @@ fn pid_parameter(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
Ok((input, result))
}
/// `pid <parameter> <value>`
/// `pid` | pid_parameter
fn pid(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
let (input, _) = tag("pid")(input)?;
let (input, _) = whitespace(input)?;
alt((
preceded(
whitespace,
pid_parameter
),
value(Ok(Command::Show(ShowCommand::Pid)), end)
))(input)
preceded(
tag("pid"),
alt((
preceded(
whitespace,
pid_parameter
),
value(Ok(Command::Show(ShowCommand::Pid)), end)
))
)(input)
}
fn command(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {