Skip to content

Commit

Permalink
Clap: Set ArgRequiredElseHelp option
Browse files Browse the repository at this point in the history
This ensures that the help is printed (with a non-0 exit code) if no
command is specified.
  • Loading branch information
dbrgn committed Oct 16, 2021
1 parent de55c05 commit e05eae7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{env, path::PathBuf, process};
use ansi_term::{Color, Style};
use app_dirs::AppInfo;
use atty::Stream;
use clap::Clap;
use clap::{AppSettings, Clap};
#[cfg(not(target_os = "windows"))]
use pager::Pager;

Expand Down Expand Up @@ -53,6 +53,8 @@ const PAGER_COMMAND: &str = "less -R";

#[derive(Clap, Debug)]
#[clap(about = "A fast TLDR client", author, version)]
#[clap(setting = AppSettings::ArgRequiredElseHelp)]
#[clap(setting = AppSettings::HelpRequired)]
struct Args {
/// The command to show (e.g. `tar` or `git log`)
#[clap(min_values = 1)]
Expand Down

0 comments on commit e05eae7

Please sign in to comment.