Skip to content

Commit

Permalink
wip done for the day i cant i just cant please send help
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Mar 4, 2024
1 parent 9d1ad73 commit f77e8b4
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions examples/cpp/external_data_loader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,7 @@
#include <string>

#include <rerun.hpp>

static const char* USAGE = R"(
This is an example executable data-loader plugin for the Rerun Viewer.
Any executable on your `$PATH` with a name that starts with `rerun-loader-` will be treated as an
external data-loader.
This particular one will log C++ source code files as markdown documents, and return a
special exit code to indicate that it doesn't support anything else.
To try it out, compile it and place it in your $PATH as `rerun-loader-cpp-file`, then open a C++ source
file with Rerun (`rerun file.cpp`).
USAGE:
rerun-loader-cpp-file [OPTIONS] FILEPATH
FLAGS:
-h, --help Prints help information
OPTIONS:
--recording-id RECORDING_ID ID of the shared recording
ARGS:
<FILEPATH>
)";
#include <rerun/third_party/cxxopts.hpp>

int main(int argc, char* argv[]) {
// The Rerun Viewer will always pass these two pieces of information:
Expand Down Expand Up @@ -56,11 +33,45 @@ int main(int argc, char* argv[]) {
}
}

if (filepath.empty()) {
std::cerr << USAGE << std::endl;
return 1;
// if (filepath.empty()) {
// std::cerr << USAGE << std::endl;
// return 1;
// }

cxxopts::Options options(
"rerun-loader-cpp-file",
R"(
This is an example executable data-loader plugin for the Rerun Viewer.
Any executable on your `$PATH` with a name that starts with `rerun-loader-` will be treated as an
external data-loader.
This particular one will log C++ source code files as markdown documents, and return a
special exit code to indicate that it doesn't support anything else.
To try it out, compile it and place it in your $PATH as `rerun-loader-cpp-file`, then open a C++ source
file with Rerun (`rerun file.cpp`).
)"
);

// clang-format off
options.add_options()
("h,help", "Print usage")
("from-contents", "Log the contents of the file directly (files only -- not supported by external loaders)", cxxopts::value<bool>()->default_value("false"))
("filepath", "The filepath to be loaded and logged", cxxopts::value<std::string>())
;
// clang-format on

options.parse_positional({"filepath"});

auto args = options.parse(argc, argv);

if (args.count("help")) {
std::cout << options.help() << std::endl;
exit(0);
}

std::cout << args << std::endl;

bool is_file = std::filesystem::is_regular_file(filepath);
bool is_cpp_file = std::filesystem::path(filepath).extension().string() == ".cpp";

Expand Down

0 comments on commit f77e8b4

Please sign in to comment.