Skip to content

Commit 64e1e5a

Browse files
authored
Merge branch 'master' into user/jlaans/452
2 parents e3a7fa6 + b95c4f3 commit 64e1e5a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

cppwinrt/cmd_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ namespace cppwinrt
515515
template<typename O, typename L>
516516
void extract_option(std::string_view arg, O const& options, L& last)
517517
{
518-
if (arg[0] == '-')
518+
if (arg[0] == '-' || arg[0] == '/')
519519
{
520520
arg.remove_prefix(1);
521521
last = find(options, arg);

cppwinrt/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace cppwinrt
3131
{ "base", 0, 0, {}, "Generate base.h unconditionally" },
3232
{ "optimize", 0, 0, {}, "Generate component projection with unified construction support" },
3333
{ "help", 0, option::no_max, {}, "Show detailed help with examples" },
34+
{ "?", 0, option::no_max, {}, {} },
3435
{ "library", 0, 1, "<prefix>", "Specify library prefix (defaults to winrt)" },
3536
{ "filter" }, // One or more prefixes to include in input (same as -include)
3637
{ "license", 0, 0 }, // Generate license comment
@@ -252,7 +253,7 @@ Where <spec> is one or more of:
252253

253254
reader args{ argc, argv, options };
254255

255-
if (!args || args.exists("help"))
256+
if (!args || args.exists("help") || args.exists("?"))
256257
{
257258
throw usage_exception{};
258259
}
@@ -362,11 +363,11 @@ Where <spec> is one or more of:
362363
}
363364
catch (std::exception const& e)
364365
{
365-
w.write(" error: %\n", e.what());
366+
w.write("cppwinrt : error %\n", e.what());
366367
result = 1;
367368
}
368369

369-
w.flush_to_console();
370+
w.flush_to_console(result == 0);
370371
return result;
371372
}
372373
}

cppwinrt/text_writer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ namespace cppwinrt
145145
std::swap(m_second, m_first);
146146
}
147147

148-
void flush_to_console() noexcept
148+
void flush_to_console(bool to_stdout = true) noexcept
149149
{
150-
printf("%.*s", static_cast<int>(m_first.size()), m_first.data());
151-
printf("%.*s", static_cast<int>(m_second.size()), m_second.data());
150+
fprintf(to_stdout ? stdout : stderr, "%.*s", static_cast<int>(m_first.size()), m_first.data());
151+
fprintf(to_stdout ? stdout : stderr, "%.*s", static_cast<int>(m_second.size()), m_second.data());
152152
m_first.clear();
153153
m_second.clear();
154154
}

0 commit comments

Comments
 (0)