Parse the FVM network and set the global value.
(s: &str)
| 75 | |
| 76 | /// Parse the FVM network and set the global value. |
| 77 | fn parse_network(s: &str) -> Result<Network, String> { |
| 78 | match s.to_lowercase().as_str() { |
| 79 | "main" | "mainnet" | "f" => Ok(Network::Mainnet), |
| 80 | "test" | "testnet" | "t" => Ok(Network::Testnet), |
| 81 | n => { |
| 82 | let n: u8 = n |
| 83 | .parse() |
| 84 | .map_err(|e| format!("expected 0 or 1 for network: {e}"))?; |
| 85 | |
| 86 | let n = Network::from_u8(n).ok_or_else(|| format!("unexpected network: {s}"))?; |
| 87 | |
| 88 | Ok(n) |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | fn dir_of(path: &str) -> PathBuf { |
| 94 | let p = Path::new(path); |