This repository was archived by the owner on Aug 23, 2022. It is now read-only.
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
Rewrite proposal #27
Open
Description
Hello!
After talking about thunder with @spacekookie, she told me about a effort to rewrite thunder to have a better usability and code.
Thinking about that, I thought about proposing a new way to write thunder apps.
So far my proposal would make a simple hello world look like this:
#![feature(use_extern_macros)]
extern crate thunder_derive;
extern crate thunder;
#[derive(ThunderApp)]
struct Thor {
/// Bla bla bl
#[thunder(take_value = false)] // Default is to take value
drunk: bool,
/// What will be Thor's age today
#[thunder(default_value = 1342)] // Can configure flag default value
age: i32
}
#[thunderclap]
impl Thor {
/// This is a subcommand, as before
fn hello(&self, name: Option<&str>) {
println!("Hello, {}! Nice to meet you, I'm Thor and I'm {} years old", name.unwrap_or("world"), self.age);
}
fn me(&self) {
let drunk = if self.drunk {
"drunk!"
} else {
"not drunk!"
};
println!("Huh, me? I'm Thor! And I'm {}");
}
}
fn main() {
Thor::start();
}
This is strongly inspired by structopt.
The main idea is to have global args parsing work like normal args do in structopt, and subcommands work as they work right now. Thus being more flexible, while still being fast to iterate.
I couldn't think about how to make subcommand arguments as flexible, but it's on my list of things to improve too