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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use serde_reflection::Registry;
use std::str::FromStr;
use structopt::{clap::arg_enum, StructOpt};
mod consensus;
mod diem;
mod linter;
mod move_abi;
mod network;
pub use linter::lint_bcs_format;
arg_enum! {
#[derive(Debug, StructOpt, Clone, Copy)]
pub enum Corpus {
Diem,
Consensus,
Network,
MoveABI,
}
}
impl Corpus {
pub fn values() -> Vec<Corpus> {
Corpus::variants()
.iter()
.filter_map(|s| Corpus::from_str(s).ok())
.collect()
}
pub fn get_registry(self) -> Registry {
let result = match self {
Corpus::Diem => diem::get_registry(),
Corpus::Consensus => consensus::get_registry(),
Corpus::Network => network::get_registry(),
Corpus::MoveABI => move_abi::get_registry(),
};
match result {
Ok(registry) => registry,
Err(error) => {
panic!("{}:{}", error, error.explanation());
}
}
}
pub fn output_file(self) -> Option<&'static str> {
match self {
Corpus::Diem => diem::output_file(),
Corpus::Consensus => consensus::output_file(),
Corpus::Network => network::output_file(),
Corpus::MoveABI => move_abi::output_file(),
}
}
}