diff --git a/src/lexer.rs b/src/lexer.rs new file mode 100644 index 0000000..a25a5d9 --- /dev/null +++ b/src/lexer.rs @@ -0,0 +1,50 @@ +/* Pirate - A command-line arrrrguments parser, written in Rust. + * Copyright (C) 2015 Zachary Dziura + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use std::fmt::{self, Display, Formatter}; + +pub fn analyze(input: &str) -> Result { + +} + +pub struct Result { + short_name: String, + long_name: String, + is_arg: bool, + has_arg: bool, + description: String +} + +impl Result { + pub fn new(short_name: &str, long_name: &str, is_arg: bool, has_arg: bool, description: &str) + -> Result { + Result { + short_name: String::from(short_name), + long_name: String::from(long_name), + is_arg: is_arg, + has_arg: has_arg, + description: String::from(description) + } + } +} + +impl Display for Result { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + let repr = format!("-{}, --{} {}", self.short_name, self.long_name, self.description); + write(self, "{}", repr) + } +} \ No newline at end of file