mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-22 07:58:02 +00:00
Metadata difference command (#1015)
* diffing pallets and runtime apis * print diff * clippy fix and format * change formatting * fmt * diff working with storage details * fix diff * cargo fmt * remove printing of node * change strings * handle parsing differently * clippy fix * cargo fmt * more abstraction * clippy fix and fmt * add unit test and ordering * fix small issue
This commit is contained in:
+26
-1
@@ -5,14 +5,16 @@
|
||||
use clap::Args;
|
||||
use color_eyre::eyre;
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::{fs, io::Read, path::PathBuf};
|
||||
|
||||
use subxt_codegen::utils::{MetadataVersion, Uri};
|
||||
|
||||
pub mod type_description;
|
||||
pub mod type_example;
|
||||
|
||||
/// The source of the metadata.
|
||||
#[derive(Debug, Args)]
|
||||
#[derive(Debug, Args, Clone)]
|
||||
pub struct FileOrUrl {
|
||||
/// The url of the substrate node to query for metadata for codegen.
|
||||
#[clap(long, value_parser)]
|
||||
@@ -94,3 +96,26 @@ pub fn with_indent(s: String, indent: usize) -> String {
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
impl FromStr for FileOrUrl {
|
||||
type Err = &'static str;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let path = std::path::Path::new(s);
|
||||
if path.exists() {
|
||||
Ok(FileOrUrl {
|
||||
url: None,
|
||||
file: Some(PathBuf::from(s)),
|
||||
version: None,
|
||||
})
|
||||
} else {
|
||||
Uri::from_str(s)
|
||||
.map_err(|_| "no path or uri could be crated")
|
||||
.map(|uri| FileOrUrl {
|
||||
url: Some(uri),
|
||||
file: None,
|
||||
version: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user