static Catalog findNearestCatalogWith(Path dir, boolean includeImported, boolean includeImplicits,
			Function<Catalog, Catalog> accept) {
		Catalog catalog = Util.findNearestWith(dir, JBANG_CATALOG_JSON, p -> {
			try {
				Catalog cat = get(p);
				return accept.apply(cat);
			} catch (Exception e) {
				Util.warnMsg("Unable to read catalog " + p + " because " + e);
				return null;
			}
		});
		if (catalog == null && includeImported) {
			catalog = Util.findNearestWith(dir, JBANG_CATALOG_JSON, p -> {
				try {
					Catalog cat = get(p);
					return findImportedCatalogsWith(cat, accept);
				} catch (Exception e) {
					Util.warnMsg("Unable to read catalog " + p + " because " + e);
					return null;
				}
			});
		}
		if (catalog == null && includeImplicits) {
			Path file = Settings.getUserImplicitCatalogFile();
			if (Files.isRegularFile(file) && Files.isReadable(file)) {
				try {
					Catalog cat = get(file);
					catalog = accept.apply(cat);
				} catch (Exception e) {
					Util.warnMsg("Unable to read catalog " + file + " because " + e);
					return null;
				}
			}
		}
		if (catalog == null) {
			catalog = accept.apply(getBuiltin());
			if (catalog == null && includeImported) {
				catalog = findImportedCatalogsWith(getBuiltin(), accept);
			}
		}
		return catalog;
	}
Returns a Catalog containing all the aliases from local catalog files merged
into one. This follows the system where aliases that are "nearest" have
priority.

@param includeImplicits Determines if the implicit catalogs should be merged
                        or not
@return a Catalog object
src/main/java/dev/jbang/catalog/Catalog.java