summaryrefslogtreecommitdiff
path: root/vulkaninfo/vulkaninfo.cpp
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2021-11-16 19:51:45 -0700
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2021-11-29 13:03:31 -0700
commite9cc9eefa6a3ee1b20269f323fc577f3e9473d76 (patch)
tree4b81ecd682ce44314c9a0cc585272d6c4170d993 /vulkaninfo/vulkaninfo.cpp
parentdb7ac7a7a7d01ad4ee88aa3e3e6d2efb9ed7f4df (diff)
downloadVulkan-Tools-e9cc9eefa6a3ee1b20269f323fc577f3e9473d76.tar.gz
Vulkan-Tools-e9cc9eefa6a3ee1b20269f323fc577f3e9473d76.tar.bz2
Vulkan-Tools-e9cc9eefa6a3ee1b20269f323fc577f3e9473d76.zip
vulkaninfo: Error check --output
Make sure the following argument is a filename and not another argument. Also: Add `--text` as it makes sense to have it as an explicit flag even if it is the default. Move --summary to the top, since its the most useful thing to know at a glance.
Diffstat (limited to 'vulkaninfo/vulkaninfo.cpp')
-rw-r--r--vulkaninfo/vulkaninfo.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp
index 8be482e9..75443a35 100644
--- a/vulkaninfo/vulkaninfo.cpp
+++ b/vulkaninfo/vulkaninfo.cpp
@@ -818,6 +818,9 @@ void print_usage(const char *argv0) {
std::cout << "USAGE: " << argv0 << " [options]\n\n";
std::cout << "OPTIONS:\n";
std::cout << "-h, --help Print this help.\n";
+ std::cout << "--summary Show a summary of the instance and GPU's on a system.\n\n";
+ std::cout << "--text Produce a text version of vulkaninfo output to stdout. This is\n";
+ std::cout << " the default output.\n";
std::cout << "--html Produce an html version of vulkaninfo output, saved as\n";
std::cout << " \"vulkaninfo.html\" in the directory in which the command\n";
std::cout << " is run.\n";
@@ -841,7 +844,6 @@ void print_usage(const char *argv0) {
std::cout << "-o <filename>, --output<filename>\n";
std::cout << " Print output to a new file whose name is specified by filename.\n";
std::cout << " File will be written to the current working directory.\n";
- std::cout << "--summary Show a summary of the instance and GPU's on a system.\n\n";
}
struct ParsedResults {
@@ -862,8 +864,10 @@ util::trivial_optional<ParsedResults> parse_arguments(int argc, char **argv) {
// Usage "--vkconfig_output <path>"
if (0 == strcmp("--vkconfig_output", argv[i]) && argc > (i + 1)) {
results.output_category = OutputCategory::vkconfig_output;
- results.output_path = argv[i + 1];
- ++i;
+ if (argc > (i + 1) && argv[i + 1][0] != '-') {
+ results.output_path = argv[i + 1];
+ ++i;
+ }
} else if (strncmp("--json", argv[i], 6) == 0 || strcmp(argv[i], "-j") == 0) {
if (strlen(argv[i]) > 7 && strncmp("--json=", argv[i], 7) == 0) {
results.selected_gpu = static_cast<uint32_t>(strtol(argv[i] + 7, nullptr, 10));
@@ -879,6 +883,8 @@ util::trivial_optional<ParsedResults> parse_arguments(int argc, char **argv) {
#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
} else if (strcmp(argv[i], "--summary") == 0) {
results.output_category = OutputCategory::summary;
+ } else if (strcmp(argv[i], "--text") == 0) {
+ results.output_category = OutputCategory::text;
} else if (strcmp(argv[i], "--html") == 0) {
} else if (strcmp(argv[i], "--show-tool-props") == 0) {
results.show_tool_props = true;
@@ -887,6 +893,10 @@ util::trivial_optional<ParsedResults> parse_arguments(int argc, char **argv) {
} else if ((strcmp(argv[i], "--output") == 0 || strcmp(argv[i], "-o") == 0) && argc > (i + 1)) {
results.use_custom_filename = true;
results.custom_filename = argv[i + 1];
+ if (argv[i + 1][0] == '-') {
+ std::cout << "-o or --output must be followed by a filename\n";
+ return {};
+ }
++i;
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
print_usage(argv[0]);