Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: fix a panic and an infinite loop, when command flag descriptions…
… have multiple lines (#17981)
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module main | ||
|
||
import cli { Command, Flag } | ||
|
||
fn test_long_description() { | ||
mut cmd := Command{ | ||
name: 'cli' | ||
description: 'An example of the cli library.' | ||
version: '1.0.0' | ||
} | ||
mut greet_cmd := Command{ | ||
name: 'greet' | ||
description: 'Prints greeting in different languages.' | ||
usage: '<name>' | ||
required_args: 1 | ||
} | ||
greet_cmd.add_flag(Flag{ | ||
flag: .string_array | ||
name: 'fun' | ||
description: '\'{"uri":"mqtt://broker.emqx.io:1883","topic":"test_emq/1","filters":[{"producer_id":0,"trace_group":2,"string_id":3001},{"string_id":3002}]}\'' | ||
}) | ||
cmd.add_command(greet_cmd) | ||
cmd.setup() | ||
cmd.parse(['cli', 'greet', '-help']) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters