Skip to content

Conversation

@jjimenezshaw
Copy link
Contributor

@jjimenezshaw jjimenezshaw commented Dec 30, 2025

The main purpose if this PR is to allow the usage of projinfo as a library, not only as a CLI program.
That allows to call it, for instance, in the browser. See an example at https://jjimenezshaw.github.io/wasm-proj/projinfo.html

The code from the CLI was kept unmodified. To replicate the usage of std::cout and std::cerr, streams are used internally in the library, and the API is using a callback to report every call to those streams. See that some commands, like --list-crs can be very fragmented, with many calls to the callback.

For the specific usage of the callback in emscripten, a nicer helper in C++ is added to the build_wasm.sh script. That makes the usage from javascript much simpler and small.

I was not sure about the file structure to be used, and how to do it in CMake. Please, make any suggestion on that regard.

  • AI/LLM (Copilot, ChatGPT, Claude or something similar) supported my development of this PR
  • Closes #xxxx
  • Tests added
  • Added clear title that can be used to generate release notes
  • Fully documented, including updating docs/source/*.rst for new API: Where and what exactly?

#endif
return 0;
} else if (arg == "-?" || arg == "--help") {
return usage(strm);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in master is considering --help an error, and returns 1 (probably because it was simpler)
I kept the same behaviour in the code, but it is easy to change with this.

Suggested change
return usage(strm);
usage(strm);
return 0;

Should I do it?

@jjimenezshaw
Copy link
Contributor Author

cc @willcohen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant