print help with no arguments

This commit is contained in:
Raphael Jacobs 2024-02-12 21:31:47 +01:00
parent 579b5ed75b
commit 61a3a305b6
Signed by: raphy
GPG Key ID: 2987BB662DB3120B
1 changed files with 12 additions and 19 deletions

View File

@ -1,15 +1,10 @@
use std::fmt::Display;
use clap::{Parser, Subcommand, ValueEnum};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None, arg_required_else_help = true)]
pub struct Cli {
#[command(subcommand)]
pub comm: Option<Subc>,
@ -20,19 +15,20 @@ pub struct Cli {
#[derive(Subcommand, Debug)]
pub enum Subc {
Run {filename: String},
Build {filename: String, output: String},
View {
Run {
filename: String,
#[arg(short, long, default_value_t = FormatKind::FancyTable)]
format: FormatKind
},
Debug {}
Build {
filename: String,
output: String,
},
View {
filename: String,
#[arg(short, long, default_value_t = FormatKind::FancyTable)]
format: FormatKind,
},
Debug {},
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)]
@ -43,7 +39,6 @@ pub enum FormatKind {
Serializable,
}
impl Display for FormatKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
@ -54,5 +49,3 @@ impl Display for FormatKind {
}
}
}