wycats / hammer.rs

An option parsing library that deserializes flags into structs
37 stars 8 forks source link

Flag values adjacent to the flag don't parse #7

Open alexcrichton opened 10 years ago

alexcrichton commented 10 years ago
#![feature(phase)]                                                     

#[phase(plugin, link)]                                                 
extern crate hammer;                                                   
extern crate serialize;                                                

use std::os;                                                           
use serialize::Decodable;                                              

#[deriving(Encodable, Decodable)]                                      
struct Foo {                                                           
    long: uint,                                                        
}                                                                      

hammer_config!(Foo "test", |c| {                                       
    c.short("long", 'l')                                               
})                                                                     

fn main() {                                                            
    let mut d = hammer::FlagDecoder::new::<Foo>(os::args().as_slice());
    let a: Foo = Decodable::decode(&mut d).unwrap();                   

}                                                                      
$ ./foo -l3
task '<main>' failed at 'index out of bounds: the len is 2 but the index is 2', src/hammer.rs:1
wycats commented 10 years ago

Thanks! I'll get this tomorrow :smile: