aboutsummaryrefslogtreecommitdiff
path: root/src/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands.c')
-rw-r--r--src/commands.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/commands.c b/src/commands.c
index 10e4eb8..b089a1c 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -28,7 +28,7 @@ Command
28solve_cmd = { 28solve_cmd = {
29 .name = "solve", 29 .name = "solve",
30 .usage = "solve STEP [OPTIONS] SCRAMBLE", 30 .usage = "solve STEP [OPTIONS] SCRAMBLE",
31 .description = "Solve a step", 31 .description = "Solve a step; see command steps for a list of steps",
32 .parse_args = solve_parse_args, 32 .parse_args = solve_parse_args,
33 .exec = solve_exec 33 .exec = solve_exec
34}; 34};
@@ -116,6 +116,7 @@ solve_parse_args(int c, char **v)
116 a->opts->min_moves = 0; 116 a->opts->min_moves = 0;
117 a->opts->max_moves = 20; 117 a->opts->max_moves = 20;
118 a->opts->max_solutions = 1; 118 a->opts->max_solutions = 1;
119 a->opts->nthreads = 1;
119 a->opts->optimal_only = false; 120 a->opts->optimal_only = false;
120 a->opts->can_niss = false; 121 a->opts->can_niss = false;
121 a->opts->verbose = false; 122 a->opts->verbose = false;
@@ -127,7 +128,8 @@ solve_parse_args(int c, char **v)
127 val = strtol(v[++i], NULL, 10); 128 val = strtol(v[++i], NULL, 10);
128 if (val < 0 || val > 100) { 129 if (val < 0 || val > 100) {
129 fprintf(stderr, 130 fprintf(stderr,
130 "Invalid min number of moves.\n"); 131 "Invalid min number of moves"
132 "(0 <= m <= 100).\n");
131 return a; 133 return a;
132 } 134 }
133 a->opts->min_moves = val; 135 a->opts->min_moves = val;
@@ -135,10 +137,20 @@ solve_parse_args(int c, char **v)
135 val = strtol(v[++i], NULL, 10); 137 val = strtol(v[++i], NULL, 10);
136 if (val < 0 || val > 100) { 138 if (val < 0 || val > 100) {
137 fprintf(stderr, 139 fprintf(stderr,
138 "Invalid max number of moves.\n"); 140 "Invalid max number of moves"
141 "(0 <= M <= 100).\n");
139 return a; 142 return a;
140 } 143 }
141 a->opts->max_moves = val; 144 a->opts->max_moves = val;
145 } else if (!strcmp(v[i], "-t")) {
146 val = strtol(v[++i], NULL, 10);
147 if (val < 1 || val > 64) {
148 fprintf(stderr,
149 "Invalid number of threads."
150 "1 <= t <= 64\n");
151 return a;
152 }
153 a->opts->nthreads = val;
142 } else if (!strcmp(v[i], "-s")) { 154 } else if (!strcmp(v[i], "-s")) {
143 val = strtol(v[++i], NULL, 10); 155 val = strtol(v[++i], NULL, 10);
144 if (val < 1 || val > 1000000) { 156 if (val < 1 || val > 1000000) {
@@ -255,11 +267,19 @@ print_exec(CommandArgs *args)
255static void 267static void
256help_exec(CommandArgs *args) 268help_exec(CommandArgs *args)
257{ 269{
258 /* TODO: print full nissy manpage */
259 if (args->command == NULL) { 270 if (args->command == NULL) {
260 printf("Type help COMMAND for information on a "); 271 printf(
261 printf("specific command.\n"); 272 "Use the nissy command \"help COMMAND\" for a short "
262 printf("A more complete manual page is work in progress.\n"); 273 "description of a specific command.\n"
274 "Use the nissy command \"commands\" for a list of "
275 "available commands.\n"
276 "See the manual page for more details. The manual"
277 " page is available with \"man nissy\" on a UNIX"
278 " system (such a Linux or MacOS) or in pdf and html"
279 " format in the docs folder.\n"
280 "Nissy is available for free at "
281 "https://github.com/sebastianotronto/nissy"
282 );
263 } else { 283 } else {
264 printf("Command %s: %s\nusage: %s\n", args->command->name, 284 printf("Command %s: %s\nusage: %s\n", args->command->name,
265 args->command->description, args->command->usage); 285 args->command->description, args->command->usage);

Generated with cgit - Back to sebastiano.tronto.net