Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split cxxopts.hpp into multiple files #338

Open
eyalroz opened this issue Jul 6, 2022 · 4 comments
Open

Split cxxopts.hpp into multiple files #338

eyalroz opened this issue Jul 6, 2022 · 4 comments

Comments

@eyalroz
Copy link
Contributor

eyalroz commented Jul 6, 2022

One can observe a decomposition of cxxopts.hpp into several parts:

  • non-option-specific string-related code
  • Exception-related code
  • the values namespace and the Value class
  • KeyValue, Option, OptionParser and related code
  • ParseResult and some Option/OptionParser implementations which need ParseResult
  • Options, OptionAddr, help

And the above is also the order of dependencies.

Or, actually, maybe we could take this another step and have one file per (non-trivial) class, so separate files for Option, Option Adder, Options, OptionParser etc.

So, how about we split the huge single file into a file for each of these? With cxxopts.hpp remaining as an "includer" of all the others?

This will:

  • Improve source code readability
  • Make it easier to merge changes
  • Make the revision history easier to understand (when looking at the affected files)

What do you think, @jarro2783 ?

eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 6, 2022
eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 6, 2022
eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 6, 2022
eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 7, 2022
eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 7, 2022
eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 7, 2022
@jarro2783
Copy link
Owner

I always wanted this to be single header to just drop into a project, and it still doesn't seem huge yet. If there was a nice way to generate a single header then I think it could be broken up.

@eyalroz
Copy link
Contributor Author

eyalroz commented Jul 8, 2022

@jarro2783 : Why is it important to be able to drop a single file rather than a subfolder?

Anyway, to create a single header, you run:

quom cxxopts.hpp cxxopts_single.hpp

and you get quom with:

pip3 --user install quom

See also: https://stackoverflow.com/a/62218074/1593077

eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 8, 2022
eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 8, 2022
eyalroz added a commit to eyalroz/cxxopts that referenced this issue Jul 8, 2022
@jarro2783
Copy link
Owner

Yeah I guess having multiple files is not so bad. I'll look at this after some of the other changes because it will mess up PRs.

@eyalroz
Copy link
Contributor Author

eyalroz commented Jul 10, 2022

So, yeah, the different PRs tend to clash. When you decide which of them you like, I'll rebase them onto each other so that you can merge.

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 a pull request may close this issue.

2 participants