Skip to content

Commit

Permalink
full implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
elerch committed Jun 22, 2017
1 parent e0c2665 commit 227813c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/main.rs
Expand Up @@ -44,10 +44,12 @@ fn operations(service: &Value) -> Result<Vec<String>> {
fn parameters(service: &Value, operation: String,
f: &Fn(ParameterType, &str, &Value)) {
let operation = service["operations"][operation].as_object().unwrap();
let input = operation["input"]["shape"].as_str().unwrap();
// let errors = operation["errors"].as_array().unwrap(); // ignore errors for now
let ref shapes = service["shapes"];
f(ParameterType::Input, input, &shapes[input]);
if operation.contains_key("input") {
let input = operation["input"]["shape"].as_str().unwrap();
f(ParameterType::Input, input, &shapes[input]);
}
// let errors = operation["errors"].as_array().unwrap(); // ignore errors for now
if operation.contains_key("output") {
let output = operation["output"]["shape"].as_str().unwrap();
f(ParameterType::Output, output, &shapes[output]);
Expand Down Expand Up @@ -81,18 +83,18 @@ fn service_files(basepath: Option<&str>) -> Result<HashMap<String, String>> {
if entrypath.is_dir() {
let servicename = entry.file_name();
let mut newest = std::ffi::OsString::from("0");
//let mut newestentry = DirEntry
for serviceentry in std::fs::read_dir(entry.path())? {
let serviceentry = serviceentry?;
let current = serviceentry.file_name();
if current > newest {
newest = current;
}
}
println!("newest {:?}: {:?}", servicename.into_string(), newest.into_string());
let newestserviceentry = entrypath.join(newest).join("service-2.json");
rc.insert(servicename.into_string().unwrap(), newestserviceentry.to_str().unwrap().to_string());
}
}
rc.insert("kms".to_string(), path + &("/kms/2014-11-01/service-2.json".to_string()));
//rc.insert("kms".to_string(), path + &("/kms/2014-11-01/service-2.json".to_string()));
Ok(rc)
}

Expand All @@ -107,11 +109,11 @@ fn service_files(basepath: Option<&str>) -> Result<HashMap<String, String>> {
fn main() {
for (service, file) in service_files(None).unwrap() {
println!("{}", service);
println!(" {}", file);
// let j: Value = json_from_path(file).unwrap();
// for operation in operations(&j).unwrap() {
// println!(" {}", operation);
// parameters(&j, operation, &print_parameters);
// }
//println!(" {}", file);
let j: Value = json_from_path(file).unwrap();
for operation in operations(&j).unwrap() {
println!(" {}", operation);
parameters(&j, operation, &print_parameters);
}
}
}

0 comments on commit 227813c

Please sign in to comment.