print help with no arguments
This commit is contained in:
parent
579b5ed75b
commit
61a3a305b6
@ -1,15 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use clap::{Parser, Subcommand, ValueEnum};
|
use clap::{Parser, Subcommand, ValueEnum};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[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 {
|
pub struct Cli {
|
||||||
|
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub comm: Option<Subc>,
|
pub comm: Option<Subc>,
|
||||||
|
|
||||||
@ -20,19 +15,20 @@ pub struct Cli {
|
|||||||
|
|
||||||
#[derive(Subcommand, Debug)]
|
#[derive(Subcommand, Debug)]
|
||||||
pub enum Subc {
|
pub enum Subc {
|
||||||
|
Run {
|
||||||
Run {filename: String},
|
|
||||||
Build {filename: String, output: String},
|
|
||||||
View {
|
|
||||||
|
|
||||||
filename: String,
|
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)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)]
|
||||||
@ -43,7 +39,6 @@ pub enum FormatKind {
|
|||||||
Serializable,
|
Serializable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Display for FormatKind {
|
impl Display for FormatKind {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
@ -54,5 +49,3 @@ impl Display for FormatKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user