Skip to content

Commit

Permalink
wip: add type gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Oct 4, 2023
1 parent 8c204e1 commit b4eba52
Show file tree
Hide file tree
Showing 5 changed files with 415 additions and 10 deletions.
2 changes: 2 additions & 0 deletions spec-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ syn = { version = "1.0.98", features = [
] }
prettyplease = { version = "0.1.10" }
quote = { version = "1.0.18" }
clap = { version = "4.4.6", features = ["derive"] }
convert_case = "0.6.0"
8 changes: 2 additions & 6 deletions spec-gen/src/generator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::visitors::{
collate_generics_from, collect_lifetimes, collect_type_params, generics_to_arguments,
ArgumentsEditor, TypeNameVisitor,
as_syn_ident, collate_generics_from, collect_lifetimes, collect_type_params,
generics_to_arguments, ArgumentsEditor, TypeNameVisitor,
};
use std::{
collections::{BTreeMap, HashMap},
Expand All @@ -12,10 +12,6 @@ use syn::{parse_quote, visit_mut::VisitMut, Ident, Item};

const SOURCE_ROOT: &str = "ethereum-consensus/src";

fn as_syn_ident(s: String) -> Ident {
syn::parse_str(&s).unwrap()
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
enum Fork {
#[default]
Expand Down
24 changes: 23 additions & 1 deletion spec-gen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
mod generator;
mod type_generator;
mod visitors;

use clap::{Parser, ValueEnum};

#[derive(Parser, Debug)]
struct Args {
command: Command,
}

#[derive(ValueEnum, Debug, Clone)]
enum Command {
Forks,
Types,
}

fn main() {
generator::run();
let args = Args::parse();
match args.command {
Command::Forks => {
generator::run();
}
Command::Types => {
type_generator::run();
}
}
}
Loading

0 comments on commit b4eba52

Please sign in to comment.