CLI11 icon indicating copy to clipboard operation
CLI11 copied to clipboard

New MakeSingleHeader

Open henryiii opened this issue 5 years ago • 0 comments

We will need a new MakeSingleHeader for 2.0. Here's the current plan:

Syntax:

// [tag:name:action]
// [tag:name:end]

The tag is cli11. The valid actions are includes, code, and verbatim. Includes are reduced and sorted. A way to allow protected includes might be needed. Name created a variable with that name, or append to an existing one. Code might be stripped of comments (optionally?).

This would be then used with .make_single_header_rc (to set the tag to cli11), and with an input file:

// Header (could be from a verbatim)
{preinc}
#if defined(CLI11_COMPILE) || CLI11_COMPILE == 1
{inc}
#endif

namespace CLI {

{optional_fwd}
...

#if defined(CLI11_COMPILE) || CLI11_COMPILE == 1
{optional_inl}
#endif 
...
}  // namespace CLI

This is read in and uses Python's format function, with dictionary of variables expanded. Something like this (pseudocode):

c = Combine()
for file in "*_fwd.hpp", "*.inl":
    c += Combine(file)

with open("conf.txt") as f:
    txt = f.read()
single_header = txt.format(**c.dict)

The version, etc. could be added as it is now.

See #338.

henryiii avatar Dec 31 '19 20:12 henryiii