Skip to content

Commit

Permalink
A few minor tweaks to make compatible with build systems (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottj1s authored May 8, 2020
1 parent 08eca8b commit 9db3f9d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cppwinrt/cmd_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ namespace cppwinrt
template<typename O, typename L>
void extract_option(std::string_view arg, O const& options, L& last)
{
if (arg[0] == '-')
if (arg[0] == '-' || arg[0] == '/')
{
arg.remove_prefix(1);
last = find(options, arg);
Expand Down
5 changes: 3 additions & 2 deletions cppwinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace cppwinrt
{ "base", 0, 0, {}, "Generate base.h unconditionally" },
{ "optimize", 0, 0, {}, "Generate component projection with unified construction support" },
{ "help", 0, option::no_max, {}, "Show detailed help with examples" },
{ "?", 0, option::no_max, {}, {} },
{ "library", 0, 1, "<prefix>", "Specify library prefix (defaults to winrt)" },
{ "filter" }, // One or more prefixes to include in input (same as -include)
{ "license", 0, 0 }, // Generate license comment
Expand Down Expand Up @@ -252,7 +253,7 @@ Where <spec> is one or more of:

reader args{ argc, argv, options };

if (!args || args.exists("help"))
if (!args || args.exists("help") || args.exists("?"))
{
throw usage_exception{};
}
Expand Down Expand Up @@ -366,7 +367,7 @@ Where <spec> is one or more of:
result = 1;
}

w.flush_to_console();
w.flush_to_console(result == 0);
return result;
}
}
Expand Down
6 changes: 3 additions & 3 deletions cppwinrt/text_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ namespace cppwinrt
std::swap(m_second, m_first);
}

void flush_to_console() noexcept
void flush_to_console(bool to_stdout = true) noexcept
{
printf("%.*s", static_cast<int>(m_first.size()), m_first.data());
printf("%.*s", static_cast<int>(m_second.size()), m_second.data());
fprintf(to_stdout ? stdout : stderr, "%.*s", static_cast<int>(m_first.size()), m_first.data());
fprintf(to_stdout ? stdout : stderr, "%.*s", static_cast<int>(m_second.size()), m_second.data());
m_first.clear();
m_second.clear();
}
Expand Down

0 comments on commit 9db3f9d

Please sign in to comment.