forked from clap-rs/clap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.rs
32 lines (26 loc) · 751 Bytes
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use clap::{App, Arg, ValueHint};
use clap_complete::{generate, shells::*, Generator};
use std::fmt;
mod bash;
mod elvish;
mod fish;
mod powershell;
mod zsh;
#[derive(PartialEq, Eq)]
pub struct PrettyString<'a>(pub &'a str);
impl<'a> fmt::Debug for PrettyString<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(self.0)
}
}
macro_rules! assert_eq {
($left:expr, $right:expr) => {
pretty_assertions::assert_eq!(PrettyString($left), PrettyString($right));
};
}
pub fn common<G: Generator>(gen: G, app: &mut App, name: &str, fixture: &str) {
let mut buf = vec![];
generate(gen, app, name, &mut buf);
let string = String::from_utf8(buf).unwrap();
assert_eq!(&string, fixture);
}