Skip to content

Commit

Permalink
improve --help output
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Nov 23, 2023
1 parent 86af961 commit 546cf04
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions v2/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,23 @@ impl Default for Options {
}

impl Options {
const USAGE: &'static str = r#"
Usage: shiba [options...] [PATH...]
const USAGE: &'static str = r#"Usage: shiba [OPTIONS...] [PATH...]
Options:
-t, --theme THEME Window theme ("dark", "light" or "system")
--no-watch Disable to watch file changes
--generate-config-file Generate the default config file overwriting an existing file
--config-dir PATH Custom the config directory path
--data-dir PATH Custom the data directory path
--debug Enable debug features
-h, --help Print this help
"#;
Shiba is a markdown preview application to be used with your favorite text
editor, designed for simplicity, performance, and keyboard-friendliness.
Options:
-t, --theme THEME Window theme ("dark", "light" or "system")
--no-watch Disable to watch file changes
--generate-config-file Generate the default config file overwriting an existing file
--config-dir PATH Change the config directory path
--data-dir PATH Change the application data directory path
--debug Enable debug features
-h, --help Print this help
Document:
https://github.com/rhysd/Shiba/v2/README.md
"#;

pub fn parse(args: impl Iterator<Item = String>) -> Result<Parsed> {
use lexopt::prelude::*;
Expand Down Expand Up @@ -220,9 +225,7 @@ mod tests {
fn help_option() {
match Options::parse(cmdline(&["--help"])).unwrap() {
Parsed::Options(opts) => panic!("--help is not recognized: {opts:?}"),
Parsed::Help(help) => {
assert!(help.contains("Usage: shiba [options...] [PATH...]"), "{help:?}")
}
Parsed::Help(help) => assert_eq!(help, Options::USAGE),
}
}

Expand Down

0 comments on commit 546cf04

Please sign in to comment.