aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-04-05 20:45:00 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2022-04-05 20:45:00 +0200
commitbb9165edd25aa4d8c5df514764a281a14ac79316 (patch)
treed7f9c0fafde3bfd10165c023200ce18985e0e818 /src
parentad0a413b40cc95e240f8a83fa21a709b4ab2b1bb (diff)
Add -help to CI tests.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7dd82f173..fc8792ceb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2550,6 +2550,7 @@ int main(int arg_count, char const **arg_ptr) {
String command = args[1];
String init_filename = {};
String run_args_string = {};
+ isize last_non_run_arg = args.count;
bool run_output = false;
if (command == "run" || command == "test") {
@@ -2565,7 +2566,6 @@ int main(int arg_count, char const **arg_ptr) {
Array<String> run_args = array_make<String>(heap_allocator(), 0, arg_count);
defer (array_free(&run_args));
- isize last_non_run_arg = args.count;
for_array(i, args) {
if (args[i] == "--") {
last_non_run_arg = i;
@@ -2675,7 +2675,15 @@ int main(int arg_count, char const **arg_ptr) {
// The command must be build, run, test, check, or another that takes a directory or filename.
if (!path_is_directory(init_filename)) {
// Input package is a filename. We allow this only if `-file` was given, otherwise we exit with an error message.
- if (!(args.count > 3 && args[3] == "-file")) {
+ bool single_file_package = false;
+ for_array(i, args) {
+ if (i >= 3 && i <= last_non_run_arg && args[i] == "-file") {
+ single_file_package = true;
+ break;
+ }
+ }
+
+ if (!single_file_package) {
gb_printf_err("ERROR: `%.*s %.*s` takes a package as its first argument.\n", LIT(args[0]), LIT(command));
gb_printf_err("Did you mean `%.*s %.*s %.*s -file`?\n", LIT(args[0]), LIT(command), LIT(init_filename));
gb_printf_err("The `-file` flag tells it to treat a file as a self-contained package.\n");