1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #include <iostream> 20 #include <fstream> 21 22 #include "Compiler.hh" 23 #include "ValidSchema.hh" 24 main(int argc,char ** argv)25int main(int argc, char** argv) { 26 int ret = 0; 27 try { 28 internal_avro::ValidSchema schema; 29 if (argc > 1) { 30 std::ifstream in(argv[1]); 31 internal_avro::compileJsonSchema(in, schema); 32 } else { 33 internal_avro::compileJsonSchema(std::cin, schema); 34 } 35 36 if (argc > 2) { 37 std::ofstream out(argv[2]); 38 schema.toFlatList(out); 39 } else { 40 schema.toFlatList(std::cout); 41 } 42 } 43 catch (std::exception& e) { 44 std::cerr << "Failed to parse or compile schema: " << e.what() << std::endl; 45 ret = 1; 46 } 47 48 return ret; 49 } 50