diff options
Diffstat (limited to 'src/commands.h')
| -rw-r--r-- | src/commands.h | 194 |
1 files changed, 193 insertions, 1 deletions
diff --git a/src/commands.h b/src/commands.h index b7a4c36..5d9f4ee 100644 --- a/src/commands.h +++ b/src/commands.h | |||
| @@ -9,6 +9,198 @@ | |||
| 9 | void free_args(CommandArgs *args); | 9 | void free_args(CommandArgs *args); |
| 10 | CommandArgs * new_args(); | 10 | CommandArgs * new_args(); |
| 11 | 11 | ||
| 12 | extern Command * commands[]; | 12 | /* Arg parsing functions *****************************************************/ |
| 13 | |||
| 14 | CommandArgs * gen_parse_args(int c, char **v); | ||
| 15 | CommandArgs * help_parse_args(int c, char **v); | ||
| 16 | CommandArgs * parse_only_scramble(int c, char **v); | ||
| 17 | CommandArgs * parse_no_arg(int c, char **v); | ||
| 18 | CommandArgs * solve_parse_args(int c, char **v); | ||
| 19 | CommandArgs * scramble_parse_args(int c, char **v); | ||
| 20 | |||
| 21 | /* Exec functions ************************************************************/ | ||
| 22 | |||
| 23 | void gen_exec(CommandArgs *args); | ||
| 24 | void cleanup_exec(CommandArgs *args); | ||
| 25 | void invert_exec(CommandArgs *args); | ||
| 26 | void solve_exec(CommandArgs *args); | ||
| 27 | void scramble_exec(CommandArgs *args); | ||
| 28 | void steps_exec(CommandArgs *args); | ||
| 29 | void commands_exec(CommandArgs *args); | ||
| 30 | void freemem_exec(CommandArgs *args); | ||
| 31 | void print_exec(CommandArgs *args); | ||
| 32 | void twophase_exec(CommandArgs *args); | ||
| 33 | void help_exec(CommandArgs *args); | ||
| 34 | void quit_exec(CommandArgs *args); | ||
| 35 | void unniss_exec(CommandArgs *args); | ||
| 36 | void version_exec(CommandArgs *args); | ||
| 37 | |||
| 38 | /* Commands ******************************************************************/ | ||
| 39 | |||
| 40 | #ifndef COMMANDS_C | ||
| 41 | |||
| 42 | extern Command cleanup_cmd; | ||
| 43 | extern Command commands_cmd; | ||
| 44 | extern Command freemem_cmd; | ||
| 45 | extern Command gen_cmd; | ||
| 46 | extern Command help_cmd; | ||
| 47 | extern Command invert_cmd; | ||
| 48 | extern Command print_cmd; | ||
| 49 | extern Command quit_cmd; | ||
| 50 | extern Command scramble_cmd; | ||
| 51 | extern Command solve_cmd; | ||
| 52 | extern Command steps_cmd; | ||
| 53 | extern Command unniss_cmd; | ||
| 54 | extern Command version_cmd; | ||
| 55 | |||
| 56 | extern Command *commands[]; | ||
| 57 | |||
| 58 | #else | ||
| 59 | |||
| 60 | Command | ||
| 61 | solve_cmd = { | ||
| 62 | .name = "solve", | ||
| 63 | .usage = "solve STEP [OPTIONS] SCRAMBLE", | ||
| 64 | .description = "Solve a step; see command steps for a list of steps", | ||
| 65 | .parse_args = solve_parse_args, | ||
| 66 | .exec = solve_exec | ||
| 67 | }; | ||
| 68 | |||
| 69 | Command | ||
| 70 | scramble_cmd = { | ||
| 71 | .name = "scramble", | ||
| 72 | .usage = "scramble [TYPE] [-n N]", | ||
| 73 | .description = "Get a random-position scramble", | ||
| 74 | .parse_args = scramble_parse_args, | ||
| 75 | .exec = scramble_exec, | ||
| 76 | }; | ||
| 77 | |||
| 78 | Command | ||
| 79 | gen_cmd = { | ||
| 80 | .name = "gen", | ||
| 81 | .usage = "gen [-t N]", | ||
| 82 | .description = "Generate all tables [using N threads]", | ||
| 83 | .parse_args = gen_parse_args, | ||
| 84 | .exec = gen_exec | ||
| 85 | }; | ||
| 86 | |||
| 87 | Command | ||
| 88 | invert_cmd = { | ||
| 89 | .name = "invert", | ||
| 90 | .usage = "invert SCRAMBLE]", | ||
| 91 | .description = "Invert a scramble", | ||
| 92 | .parse_args = parse_only_scramble, | ||
| 93 | .exec = invert_exec, | ||
| 94 | }; | ||
| 95 | |||
| 96 | Command | ||
| 97 | steps_cmd = { | ||
| 98 | .name = "steps", | ||
| 99 | .usage = "steps", | ||
| 100 | .description = "List available steps", | ||
| 101 | .parse_args = parse_no_arg, | ||
| 102 | .exec = steps_exec | ||
| 103 | }; | ||
| 104 | |||
| 105 | Command | ||
| 106 | commands_cmd = { | ||
| 107 | .name = "commands", | ||
| 108 | .usage = "commands", | ||
| 109 | .description = "List available commands", | ||
| 110 | .parse_args = parse_no_arg, | ||
| 111 | .exec = commands_exec | ||
| 112 | }; | ||
| 113 | |||
| 114 | Command | ||
| 115 | freemem_cmd = { | ||
| 116 | .name = "freemem", | ||
| 117 | .usage = "freemem", | ||
| 118 | .description = "free large tables from RAM", | ||
| 119 | .parse_args = parse_no_arg, | ||
| 120 | .exec = freemem_exec, | ||
| 121 | }; | ||
| 122 | |||
| 123 | Command | ||
| 124 | print_cmd = { | ||
| 125 | .name = "print", | ||
| 126 | .usage = "print SCRAMBLE", | ||
| 127 | .description = "Print written description of the cube", | ||
| 128 | .parse_args = parse_only_scramble, | ||
| 129 | .exec = print_exec, | ||
| 130 | }; | ||
| 131 | |||
| 132 | Command | ||
| 133 | help_cmd = { | ||
| 134 | .name = "help", | ||
| 135 | .usage = "help [COMMAND]", | ||
| 136 | .description = "Display nissy manual page or help on specific command", | ||
| 137 | .parse_args = help_parse_args, | ||
| 138 | .exec = help_exec, | ||
| 139 | }; | ||
| 140 | |||
| 141 | Command | ||
| 142 | twophase_cmd = { | ||
| 143 | .name = "twophase", | ||
| 144 | .usage = "twophase", | ||
| 145 | .description = "Find a solution quickly using a 2-phase method", | ||
| 146 | .parse_args = parse_only_scramble, | ||
| 147 | .exec = twophase_exec, | ||
| 148 | }; | ||
| 149 | |||
| 150 | Command | ||
| 151 | quit_cmd = { | ||
| 152 | .name = "quit", | ||
| 153 | .usage = "quit", | ||
| 154 | .description = "Quit nissy", | ||
| 155 | .parse_args = parse_no_arg, | ||
| 156 | .exec = quit_exec, | ||
| 157 | }; | ||
| 158 | |||
| 159 | Command | ||
| 160 | cleanup_cmd = { | ||
| 161 | .name = "cleanup", | ||
| 162 | .usage = "cleanup SCRAMBLE", | ||
| 163 | .description = "Rewrite a scramble using only standard moves (HTM)", | ||
| 164 | .parse_args = parse_only_scramble, | ||
| 165 | .exec = cleanup_exec, | ||
| 166 | }; | ||
| 167 | |||
| 168 | Command | ||
| 169 | unniss_cmd = { | ||
| 170 | .name = "unniss", | ||
| 171 | .usage = "unniss SCRAMBLE", | ||
| 172 | .description = "Rewrite a scramble without NISS", | ||
| 173 | .parse_args = parse_only_scramble, | ||
| 174 | .exec = unniss_exec, | ||
| 175 | }; | ||
| 176 | |||
| 177 | Command | ||
| 178 | version_cmd = { | ||
| 179 | .name = "version", | ||
| 180 | .usage = "version", | ||
| 181 | .description = "print nissy version", | ||
| 182 | .parse_args = parse_no_arg, | ||
| 183 | .exec = version_exec, | ||
| 184 | }; | ||
| 185 | |||
| 186 | Command *commands[] = { | ||
| 187 | &commands_cmd, | ||
| 188 | &freemem_cmd, | ||
| 189 | &gen_cmd, | ||
| 190 | &help_cmd, | ||
| 191 | &invert_cmd, | ||
| 192 | &print_cmd, | ||
| 193 | &quit_cmd, | ||
| 194 | &solve_cmd, | ||
| 195 | &scramble_cmd, | ||
| 196 | &steps_cmd, | ||
| 197 | &twophase_cmd, | ||
| 198 | &cleanup_cmd, | ||
| 199 | &unniss_cmd, | ||
| 200 | &version_cmd, | ||
| 201 | NULL | ||
| 202 | }; | ||
| 203 | |||
| 204 | #endif | ||
| 13 | 205 | ||
| 14 | #endif | 206 | #endif |
