mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 15:25:06 +02:00
Add the default help flag
This commit is contained in:
@ -54,6 +54,16 @@ impl Eq for Signature {}
|
||||
|
||||
impl Signature {
|
||||
pub fn new(name: impl Into<String>) -> Signature {
|
||||
// default help flag
|
||||
let flag = Flag {
|
||||
long: "help".into(),
|
||||
short: Some('h'),
|
||||
arg: None,
|
||||
desc: "Display this help message".into(),
|
||||
required: false,
|
||||
var_id: None,
|
||||
};
|
||||
|
||||
Signature {
|
||||
name: name.into(),
|
||||
usage: String::new(),
|
||||
@ -61,7 +71,7 @@ impl Signature {
|
||||
required_positional: vec![],
|
||||
optional_positional: vec![],
|
||||
rest_positional: None,
|
||||
named: vec![],
|
||||
named: vec![flag],
|
||||
is_filter: false,
|
||||
creates_scope: false,
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ where
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
pub struct Span {
|
||||
pub start: usize,
|
||||
pub end: usize,
|
||||
@ -37,6 +37,10 @@ impl Span {
|
||||
end: self.end - offset,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn contains(&self, pos: usize) -> bool {
|
||||
pos >= self.start && pos < self.end
|
||||
}
|
||||
}
|
||||
|
||||
pub fn span(spans: &[Span]) -> Span {
|
||||
|
Reference in New Issue
Block a user