Commit 365c90096c82f443a99065250beb66742a261e9d

Con Kolivas 2011-07-21T12:25:21

Make it possible to enter server credentials with curses input if none are specified on the command line.

diff --git a/main.c b/main.c
index 309b0c6..06fcf74 100644
--- a/main.c
+++ b/main.c
@@ -2629,9 +2629,6 @@ int main (int argc, char *argv[])
 	if (argc != 1)
 		quit(1, "Unexpected extra commandline arguments");
 
-	if (!total_pools)
-		quit(1, "No server specified");
-
 	if (total_devices) {
 		if (total_devices > nDevs)
 			quit(1, "More devices specified than exist");
@@ -2671,6 +2668,48 @@ int main (int argc, char *argv[])
 		test_and_set(&curses_active);
 	}
 
+	if (!total_pools) {
+		if (curses_active) {
+			char *input, *seterr;
+
+			immedok(logwin, true);
+			leaveok(logwin, false);
+			wprintw(logwin, "No server specified on command line. Enter details manually\n");
+
+			input = malloc(255);
+			if (!input)
+				quit(1, "Failed to malloc input");
+			wprintw(logwin, "URL: ");
+			wgetnstr(logwin, input, 255);
+			seterr = set_url(input, NULL);
+			if (seterr)
+				quit(1, "%s", seterr);
+
+			input = malloc(255);
+			if (!input)
+				quit(1, "Failed to malloc input");
+			wprintw(logwin, "Username: ");
+			wgetnstr(logwin, input, 255);
+			seterr = set_user(input, NULL);
+			if (seterr)
+				quit(1, "%s", seterr);
+
+			input = malloc(255);
+			if (!input)
+				quit(1, "Failed to malloc input");
+			wprintw(logwin, "Password: ");
+			wgetnstr(logwin, input, 255);
+			seterr = set_pass(input, NULL);
+			if (seterr)
+				quit(1, "%s", seterr);
+
+			wclear(logwin);
+			leaveok(logwin, true);
+			immedok(logwin, false);
+		} else
+			quit(1, "No server specified");
+	}
+
 	for (i = 0; i < total_pools; i++) {
 		struct pool *pool = &pools[i];