Skip to content

Commit

Permalink
[WIP] Add a --without-id/-w option to bundle without identifiers
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Jun 17, 2024
1 parent 25fe93d commit b2a8e00
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4
noa https://github.com/sourcemeta/noa 2bc3138b80e575786bec418c91fc2058c6836993
jsontoolkit https://github.com/sourcemeta/jsontoolkit e8eddd077e4d7af996fd892a19ef8ad244ff3d59
jsontoolkit https://github.com/sourcemeta/jsontoolkit 0e2ac8987382685ad6dc50ca33d2e43a6701b023
hydra https://github.com/sourcemeta/hydra 3c53d3fdef79e9ba603d48470a508cc45472a0dc
23 changes: 18 additions & 5 deletions src/command_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@

auto intelligence::jsonschema::cli::bundle(
const std::span<const std::string> &arguments) -> int {
const auto options{parse_options(arguments, {"h", "http"})};
const auto options{
parse_options(arguments, {"h", "http", "w", "without-id"})};
CLI_ENSURE(!options.at("").empty(), "You must pass a JSON Schema as input");
auto schema{sourcemeta::jsontoolkit::from_file(options.at("").front())};
sourcemeta::jsontoolkit::bundle(
schema, sourcemeta::jsontoolkit::default_schema_walker,
resolver(options, options.contains("h") || options.contains("http")))
.wait();

if (options.contains("w") || options.contains("without-id")) {
log_verbose(options) << "Bundling without using identifiers\n";
sourcemeta::jsontoolkit::bundle(
schema, sourcemeta::jsontoolkit::default_schema_walker,
resolver(options, options.contains("h") || options.contains("http")),
sourcemeta::jsontoolkit::BundleOptions::WithoutIdentifiers)
.wait();
} else {
sourcemeta::jsontoolkit::bundle(
schema, sourcemeta::jsontoolkit::default_schema_walker,
resolver(options, options.contains("h") || options.contains("http")),
sourcemeta::jsontoolkit::BundleOptions::Default)
.wait();
}

sourcemeta::jsontoolkit::prettify(
schema, std::cout, sourcemeta::jsontoolkit::schema_format_compare);
std::cout << std::endl;
Expand Down
4 changes: 4 additions & 0 deletions vendor/jsontoolkit/src/jsonschema/bundle.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b2a8e00

Please sign in to comment.