diff --git a/cppwinrt/cmd_reader.h b/cppwinrt/cmd_reader.h index b955d1e34..3dee748a3 100644 --- a/cppwinrt/cmd_reader.h +++ b/cppwinrt/cmd_reader.h @@ -515,7 +515,7 @@ namespace cppwinrt template 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); diff --git a/cppwinrt/main.cpp b/cppwinrt/main.cpp index 9c26dfc16..9a68368d0 100644 --- a/cppwinrt/main.cpp +++ b/cppwinrt/main.cpp @@ -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, "", "Specify library prefix (defaults to winrt)" }, { "filter" }, // One or more prefixes to include in input (same as -include) { "license", 0, 0 }, // Generate license comment @@ -252,7 +253,7 @@ Where 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{}; } @@ -366,7 +367,7 @@ Where is one or more of: result = 1; } - w.flush_to_console(); + w.flush_to_console(result == 0); return result; } } diff --git a/cppwinrt/text_writer.h b/cppwinrt/text_writer.h index f778bc220..5045b9395 100644 --- a/cppwinrt/text_writer.h +++ b/cppwinrt/text_writer.h @@ -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(m_first.size()), m_first.data()); - printf("%.*s", static_cast(m_second.size()), m_second.data()); + fprintf(to_stdout ? stdout : stderr, "%.*s", static_cast(m_first.size()), m_first.data()); + fprintf(to_stdout ? stdout : stderr, "%.*s", static_cast(m_second.size()), m_second.data()); m_first.clear(); m_second.clear(); }