2012-04-20 18:08:59 +10:00
|
|
|
/*
|
2018-08-04 15:14:06 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2012-04-20 18:08:59 +10:00
|
|
|
*
|
2016-06-28 15:58:41 +10:00
|
|
|
* Copyright 2012-2016 Danny Robson <danny@nerdcruft.net>
|
2012-04-20 18:08:59 +10:00
|
|
|
*/
|
|
|
|
|
2016-06-28 15:58:41 +10:00
|
|
|
#include "io.hpp"
|
2015-02-03 00:07:09 +11:00
|
|
|
#include "json/except.hpp"
|
|
|
|
#include "json/tree.hpp"
|
2012-04-12 14:12:25 +10:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
|
|
|
|
2016-06-28 15:58:41 +10:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2012-04-12 14:12:25 +10:00
|
|
|
enum {
|
|
|
|
ARG_COMMAND,
|
|
|
|
ARG_INPUT,
|
|
|
|
|
|
|
|
NUM_ARGS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-06-28 15:58:41 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-04-12 14:12:25 +10:00
|
|
|
void
|
2016-06-28 15:58:41 +10:00
|
|
|
print_usage (int argc, char **argv)
|
|
|
|
{
|
2012-04-12 14:12:25 +10:00
|
|
|
(void)argc;
|
|
|
|
std::cerr << "usage: " << argv[0] << " <input>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-28 15:58:41 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-04-12 14:12:25 +10:00
|
|
|
int
|
2016-06-28 15:58:41 +10:00
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2012-04-12 14:12:25 +10:00
|
|
|
if (argc != NUM_ARGS) {
|
|
|
|
print_usage (argc, argv);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2018-08-05 14:42:02 +10:00
|
|
|
const cruft::mapped_file src (argv[ARG_INPUT]);
|
|
|
|
std::cout << *json::tree::parse (cruft::view{src}.cast<const char*> ()) << '\n';
|
2015-02-03 00:07:09 +11:00
|
|
|
} catch (const json::error& err) {
|
2012-04-12 14:12:25 +10:00
|
|
|
std::cerr << err.what () << "\n";
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|