diff --git a/Makefile.am b/Makefile.am index 428127c9..f6ae16a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -102,3 +102,13 @@ lib_LTLIBRARIES = libutil.la libutil_la_SOURCES = $(UTIL_FILES) libutil_la_CXXFLAGS = $(AM_CXXFLAGS) libutil_la_LIBADD = $(BOOST_SYSTEM_LIB) + +bin_PROGRAMS = \ + json-clean + +json_clean_SOURCES = json/clean.cpp +json_clean_DEPENDENCIES = $(top_builddir)/.libs/libutil.la +json_clean_LDFLAGS = \ + $(BOOST_LDFLAGS) \ + $(BOOST_FILESYSTEM_LIB) \ + $(top_builddir)/.libs/libutil.a diff --git a/json/clean.cpp b/json/clean.cpp new file mode 100644 index 00000000..fcdb11ef --- /dev/null +++ b/json/clean.cpp @@ -0,0 +1,39 @@ +#include "../json.hpp" + +#include +#include + +#include + +enum { + ARG_COMMAND, + ARG_INPUT, + + NUM_ARGS +}; + + +void +print_usage (int argc, char **argv) { + (void)argc; + std::cerr << "usage: " << argv[0] << " \n"; +} + + +int +main (int argc, char **argv) { + if (argc != NUM_ARGS) { + print_usage (argc, argv); + return EXIT_FAILURE; + } + + try { + boost::filesystem::path input (argv[ARG_INPUT]); + std::cout << *json::parse (input) << "\n"; + } catch (const json::error& err) { + std::cerr << err.what () << "\n"; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +}