diff options
Diffstat (limited to '')
| -rw-r--r-- | shell/shell.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/shell/shell.c b/shell/shell.c index 24ae243..42b3ccd 100644 --- a/shell/shell.c +++ b/shell/shell.c | |||
| @@ -67,6 +67,7 @@ static int64_t datasize_exec(args_t *); | |||
| 67 | static int64_t gendata_exec(args_t *); | 67 | static int64_t gendata_exec(args_t *); |
| 68 | static int64_t solve_exec(args_t *); | 68 | static int64_t solve_exec(args_t *); |
| 69 | static int64_t solve_scramble_exec(args_t *); | 69 | static int64_t solve_scramble_exec(args_t *); |
| 70 | static int64_t countmoves_exec(args_t *); | ||
| 70 | static int64_t help_exec(args_t *); | 71 | static int64_t help_exec(args_t *); |
| 71 | 72 | ||
| 72 | static int parse_args(int, char **, args_t *); | 73 | static int parse_args(int, char **, args_t *); |
| @@ -202,13 +203,20 @@ struct { | |||
| 202 | "solve_scramble", | 203 | "solve_scramble", |
| 203 | "solve_scramble " FLAG_SOLVER " SOLVER" | 204 | "solve_scramble " FLAG_SOLVER " SOLVER" |
| 204 | "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] " | 205 | "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] " |
| 205 | FLAG_CUBE " CUBE", | 206 | FLAG_MOVES " MOVES", |
| 206 | "Solve the given SCRAMBLE using SOLVER, " | 207 | "Solve the given SCRAMBLE using SOLVER, " |
| 207 | "using at least n and at most N moves. " | 208 | "using at least n and at most N moves. " |
| 208 | INFO_MOVESFORMAT, | 209 | INFO_MOVESFORMAT, |
| 209 | solve_scramble_exec | 210 | solve_scramble_exec |
| 210 | ), | 211 | ), |
| 211 | COMMAND( | 212 | COMMAND( |
| 213 | "countmoves", | ||
| 214 | "countmoves " FLAG_MOVES " MOVES", | ||
| 215 | "Count the given MOVES in HTM. " | ||
| 216 | INFO_MOVESFORMAT, | ||
| 217 | countmoves_exec | ||
| 218 | ), | ||
| 219 | COMMAND( | ||
| 212 | "help", | 220 | "help", |
| 213 | "help [" FLAG_COMMAND " COMMAND]", | 221 | "help [" FLAG_COMMAND " COMMAND]", |
| 214 | "If no COMMAND is specified, prints some generic information " | 222 | "If no COMMAND is specified, prints some generic information " |
| @@ -488,6 +496,19 @@ solve_scramble_exec(args_t *args) | |||
| 488 | } | 496 | } |
| 489 | 497 | ||
| 490 | static int64_t | 498 | static int64_t |
| 499 | countmoves_exec(args_t *args) | ||
| 500 | { | ||
| 501 | long long count; | ||
| 502 | |||
| 503 | count = nissy_countmoves(args->str_moves); | ||
| 504 | |||
| 505 | if (count >= 0) | ||
| 506 | printf("%lld\n", count); | ||
| 507 | |||
| 508 | return count >= 0 ? 0 : count; | ||
| 509 | } | ||
| 510 | |||
| 511 | static int64_t | ||
| 491 | help_exec(args_t *args) | 512 | help_exec(args_t *args) |
| 492 | { | 513 | { |
| 493 | int i; | 514 | int i; |
