-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsudoku_commands.c
733 lines (608 loc) · 22.5 KB
/
sudoku_commands.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
/******************************************************************************
* Program: sudoku_commands.c
*
* Purpose: Implements the menu-command system for users to interact with the
* program
*
* Developer: Philip Ormand
*
* Date: 5/13/16
*
*****************************************************************************/
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "sudoku_commands.h"
#include "sudoku_test_digits.h"
#include "sudoku_assistant.h"
#include "sudoku_help.h"
#define IS_ANY_INPUT_REMAINING(inputPtr) ((inputPtr)->currentIndex + 1 < (inputPtr)->string.length)
#define PEEK_CHAR_FROM_INPUT_STRING_AT_INDEX(inputPtr, index) ((inputPtr)->string.array[index])
// Forward declarations, so function names are visible for definition of 'commands' array
SudokuCommandResult commandNew(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandLoad(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandCheck(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandChange(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandAssist(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandSolve(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandDisplay(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandUndo(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandRedo(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandHelp(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandExit(SudokuBoard *board, SudokuCommandInput *input);
SudokuCommandResult commandCommands(SudokuBoard *board, SudokuCommandInput *input);
#define SUDOKU_COMMAND_COUNT sizeof(commands)/sizeof(*commands)
const struct SudokuCommand commands[] = {
{ "new", "Begin new sudoku game", "new <game-type>", SUDOKU_HELP_NEW, commandNew },
{ "load", "Load sudoku game from text file", "load <filename>", SUDOKU_HELP_LOAD, commandLoad },
{ "check", "Checks sudoku board to see if solution is correct", "check", SUDOKU_HELP_CHECK, commandCheck },
{ "change", "Change a square's value", "change <column-letter> <row-number> <digit>", SUDOKU_HELP_CHANGE, commandChange },
{ "assist", "Use an assistant to get suggestion", "assist <assistant-type>", SUDOKU_HELP_ASSIST, commandAssist },
{ "solve", "Let an assistant automatically fill as many squares as it can", "solve <assistant-type>", SUDOKU_HELP_SOLVE, commandSolve },
{ "display", "Displays the current state of the sudoku board", "display", SUDOKU_HELP_DISPLAY, commandDisplay },
{ "undo", "Undoes changes made to the board", "undo <number-of-steps>", SUDOKU_HELP_UNDO, commandUndo },
{ "redo", "Redoes changes that were undone", "redo <number-of-steps>", SUDOKU_HELP_REDO, commandRedo },
{ "help", "Offers details about a particular command", "help <command>", SUDOKU_HELP_HELP, commandHelp },
{ "exit", "Exit program", "exit", SUDOKU_HELP_EXIT, commandExit },
{ "commands", "Displays available commands", "commands", SUDOKU_HELP_COMMANDS, commandCommands },
};
const char *showAllCommandsPrompt = "Type 'commands' to list all available commands.";
struct SudokuBoardPreset
{
char *name;
char board[SUDOKU_ROW_COUNT][SUDOKU_COL_COUNT];
};
typedef struct SudokuBoardPreset SudokuBoardPreset;
#define SUDOKU_BOARDPRESET_NAME_LENGTH_MAX 16
#define SUDOKU_BOARDPRESET_COUNT sizeof(boardPresets)/sizeof(*boardPresets)
const SudokuBoardPreset boardPresets[] = {
{ "blank", { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, }
},
{ "easy", { 0, 0, 3, 0, 4, 2, 0, 9, 0,
0, 9, 0, 0, 6, 0, 5, 0, 0,
5, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 1, 7, 0, 0, 2, 8, 5,
0, 0, 8, 0, 0, 0, 1, 0, 0,
3, 2, 9, 0, 0, 8, 7, 0, 0,
0, 3, 0, 0, 0, 0, 0, 0, 1,
0, 0, 5, 0, 9, 0, 0, 2, 0,
0, 8, 0, 2, 1, 0, 6, 0, 0, }
},
{ "supereasy", { 7, 0, 5, 1, 0, 4, 8, 0, 6,
1, 0, 8, 0, 5, 0, 4, 9, 0,
4, 0, 3, 6, 2, 0, 0, 5, 7,
0, 7, 0, 0, 4, 2, 3, 8, 0,
0, 3, 0, 0, 1, 7, 6, 2, 9,
2, 5, 9, 3, 0, 0, 0, 0, 1,
3, 0, 0, 0, 0, 9, 5, 1, 8,
9, 1, 6, 8, 0, 5, 0, 0, 0,
0, 8, 2, 4, 7, 0, 9, 0, 3, }
},
{ "moderate", { 4, 0, 0, 9, 0, 3, 5, 0, 6,
2, 9, 1, 0, 4, 0, 0, 0, 0,
0, 0, 6, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 6, 3, 0, 7,
0, 0, 0, 0, 0, 0, 0, 0, 0,
6, 0, 2, 5, 0, 0, 0, 0, 0,
0, 0, 0, 7, 0, 0, 8, 0, 0,
0, 0, 0, 0, 6, 0, 9, 7, 1,
9, 0, 8, 1, 0, 4, 0, 0, 2, }
},
};
SudokuCommandResult commandNew(SudokuBoard *board, SudokuCommandInput *input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
const SudokuBoardPreset *preset = NULL;
char presetName[SUDOKU_BOARDPRESET_NAME_LENGTH_MAX];
int i;
// if no argument was provided for preset name
if (!getStringArgument(input, presetName, sizeof(presetName)))
{
// preset defaults to "blank"
strcpy(presetName, "blank");
}
for (i = 0; !preset && i < SUDOKU_BOARDPRESET_COUNT; ++i)
{
if (strcmp(presetName, boardPresets[i].name) == 0)
{
preset = &boardPresets[i];
}
}
// if match was found for the preset name provided
if (preset)
{
// put sudoku board back to clean, default state
initializeSudokuBoard(board);
// copy board contents from preset into sudoku board
copySudokuBoardContents(preset->board, board->contents);
// display new state of the board
printSudokuBoard(board);
}
// if no match was found
else
{
printf("Sorry, no preset found with name \"%s\"\n", presetName);
status = SUDOKU_COMMAND_FAILURE;
}
return status;
}
SudokuCommandResult commandLoad(SudokuBoard *board, SudokuCommandInput *input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
char fileName[FILENAME_MAX];
// if argument provided for filename of sudoku input file
if (getStringArgument(input, fileName, sizeof(fileName)))
{
// if filename exists and board was loaded successfully
if (loadSudokuBoard(fileName, board))
{
printf("Successfully loaded sudoku board \"%s\"\n\n", fileName);
// display new state of the board
printSudokuBoard(board);
}
else
{
status = SUDOKU_COMMAND_FAILURE;
}
}
// if no argument was provided, that's an invalid command
else
{
status = SUDOKU_COMMAND_USAGE;
}
return status;
}
SudokuCommandResult commandCheck(SudokuBoard *board, SudokuCommandInput *input)
{
struct DigitsPresent digitsPresent;
evaluateDigitsPresent(board, &digitsPresent, true);
return SUDOKU_COMMAND_SUCCESS;
}
SudokuCommandResult commandChange(SudokuBoard *board, SudokuCommandInput *input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
char column, row, value;
// if there are arguments to read
if (IS_ANY_INPUT_REMAINING(input))
{
// if any argument not present OR any arguments were invalid
if (!getColumnArgument(input, &column) ||
!getRowArgument(input, &row) ||
!getSudokuDigitArgument(input, &value))
{
status = SUDOKU_COMMAND_USAGE;
}
}
// no arguments were provided. Prompt for input
else
{
promptForColumn(&column);
promptForRow(&row);
promptForSudokuDigit(&value);
}
// all input collected, regardless of method. If we're still okay, make changes to board
if (status == SUDOKU_COMMAND_SUCCESS)
{
// all arguments read and validated
int oldValue = board->contents[row][column];
// create history item
Coord2D square;
square.col = column;
square.row = row;
addUndoStep(board->history, &square, value);
// change square value
board->contents[row][column] = value;
// if there were undo steps past this point in the stack, they are now invalidated
invalidateSubsequentRedoSteps(board->history);
printf("Changed square %c%d from %d to %d\n\n",
colLabels[column], row + 1, oldValue, value);
// display new state of board
printSudokuBoard(board);
}
return status;
}
SudokuCommandResult commandAssist(SudokuBoard *board, SudokuCommandInput *input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
const SudokuAssistant *assistant = NULL;
char assistantName[SUDOKU_ASSISTANT_NAME_LENGTH_MAX];
// if argument provided for type of assistant to use
if (getStringArgument(input, assistantName, sizeof(assistantName)))
{
// if assistant exists
if (assistant = matchAssistant(assistantName))
{
assistant->assistantFunction(board, true);
}
else
{
printf("Sorry, \"%s\" is not a valid assistant.\n", assistantName);
status = SUDOKU_COMMAND_FAILURE;
}
}
// if no argument was provided, that's an invalid command
else
{
status = SUDOKU_COMMAND_USAGE;
}
return status;
}
SudokuCommandResult commandSolve(SudokuBoard * board, SudokuCommandInput * input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
const SudokuAssistant *assistant = NULL;
char assistantName[SUDOKU_ASSISTANT_NAME_LENGTH_MAX];
// if argument provided for type of assistant to use
if (getStringArgument(input, assistantName, sizeof(assistantName)))
{
// if assistant exists
if (assistant = matchAssistant(assistantName))
{
HistoryStep currentChange = assistant->assistantFunction(board, false);
int i;
// if we got at least one suggestion
if (currentChange.newValue)
{
// only need to invalidate subsequent history items ONCE
invalidateSubsequentRedoSteps(board->history);
}
// as long as assistant keeps returning suggestions:
for (i = 1; currentChange.newValue;
currentChange = assistant->assistantFunction(board, false), ++i)
{
// create history item
addUndoStep(board->history, ¤tChange.location, currentChange.newValue);
// change square value
board->contents
[currentChange.location.row]
[currentChange.location.col] = currentChange.newValue;
// let the user know what changes are being made
printf("%2d: Changed square %c%d to %d\n",
i, colLabels[currentChange.location.col],
currentChange.location.row + 1, currentChange.newValue);
}
// if we got at least one suggestion...
if (i > 1)
{
// put gap between change-log and board-printout
putchar('\n');
// display present state of the board
printSudokuBoard(board);
}
// otherwise, let the user know
else
{
fputs(sudokuAssistantNoSuggestionMessage, stdout);
}
}
else
{
printf("Sorry, \"%s\" is not a valid assistant.\n", assistantName);
status = SUDOKU_COMMAND_FAILURE;
}
}
// if no argument was provided, that's an invalid command
else
{
status = SUDOKU_COMMAND_USAGE;
}
return status;
}
SudokuCommandResult commandDisplay(SudokuBoard *board, SudokuCommandInput *input)
{
// display present state of the board
printSudokuBoard(board);
return SUDOKU_COMMAND_SUCCESS;
}
SudokuCommandResult commandUndo(SudokuBoard *board, SudokuCommandInput *input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
unsigned stepsToUndo;
// if argument provided for stepsToUndo is missing or invalid, assume 1 undo step
if (!getUnsignedArgument(input, &stepsToUndo))
{
stepsToUndo = 1;
}
// all arguments read and validated
if (undoStep(board->history, stepsToUndo))
{
// display new state of board
putchar('\n');
printSudokuBoard(board);
}
else
{
// if undo fails, specific error message provided by restoreUndoStep
status = SUDOKU_COMMAND_FAILURE;
}
return status;
}
SudokuCommandResult commandRedo(SudokuBoard *board, SudokuCommandInput *input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
unsigned stepsToRedo;
// if argument provided for stepsToRedo is missing or invalid, assume 1 redo step
if (!getUnsignedArgument(input, &stepsToRedo))
{
stepsToRedo = 1;
}
// all arguments read and validated
if (redoStep(board->history, stepsToRedo))
{
// display new state of board
putchar('\n');
printSudokuBoard(board);
}
else
{
// if undo fails, specific error message provided by redoUndoStep
status = SUDOKU_COMMAND_FAILURE;
}
return status;
}
SudokuCommandResult commandHelp(SudokuBoard *board, SudokuCommandInput *input)
{
SudokuCommandResult status = SUDOKU_COMMAND_SUCCESS;
const struct SudokuCommand *command = NULL;
char commandName[SUDOKU_COMMAND_NAME_LENGTH_MAX];
// if argument provided for command to help with
if (getStringArgument(input, commandName, sizeof(commandName)))
{
// if command exists
if (command = matchCommand(commandName))
{
printf("\"%s\": %s\n", command->name, command->description);
printf("Usage: '%s'\n", command->usagePrompt);
printf(command->helpText);
}
else
{
printf("Sorry, \"%s\" is not a valid command.\n", commandName);
status = SUDOKU_COMMAND_FAILURE;
}
}
// if no argument was provided, that's an invalid command
else
{
status = SUDOKU_COMMAND_USAGE;
}
return status;
}
SudokuCommandResult commandExit(SudokuBoard *board, SudokuCommandInput *input)
{
puts("Goodbye!");
return SUDOKU_COMMAND_EXIT;
}
SudokuCommandResult commandCommands(SudokuBoard * board, SudokuCommandInput * input)
{
printCommands();
return SUDOKU_COMMAND_SUCCESS;
}
inline char getCharFromInputString(SudokuCommandInput *input)
{
char ch = PEEK_CHAR_FROM_INPUT_STRING_AT_INDEX(input, input->currentIndex);
if (ch)
{
// Only increment current index if received char is not null
++(input->currentIndex);
}
return ch;
}
bool validateCommandInputStartStatus(SudokuCommandInput *input)
{
bool status = true;
if (input)
{
// if the string's array is not NULL and it contains characters
if (input->string.array && input->string.length > 0)
{
// if there no more input to read
if (!IS_ANY_INPUT_REMAINING(input))
{
// 'input' cannot be read from, because there are no more chars remaining
status = false;
}
}
else
{
terminate("ERROR: tried to get string argument from an invalid String");
}
}
else
{
terminate("ERROR: tried to get string argument from a null SudokuCommandInput");
}
return status;
}
void seekToNextArgument(SudokuCommandInput *input, bool discardRestOfCurrentArgument)
{
int startIndex = input->currentIndex;
// start with char right before currentIndex if discardRestOfCurrentArgument is true.
// this checks if currentIndex is already the start of a new argument or not
if (discardRestOfCurrentArgument && input->currentIndex != 0)
{
startIndex = input->currentIndex - 1;
}
char ch = PEEK_CHAR_FROM_INPUT_STRING_AT_INDEX(input, startIndex);
// skip to the end of current argument, if any non-space characters remain
while (discardRestOfCurrentArgument &&
!isspace(ch) && ch != 0)
{
ch = getCharFromInputString(input);
}
// skip the whitespace until next argument
while (isspace(ch))
{
ch = getCharFromInputString(input);
}
// if final char fetched is a valid input char, put it "back" into the input string
if (discardRestOfCurrentArgument && !isspace(ch))
{
--(input->currentIndex);
}
}
bool getStringArgument(SudokuCommandInput * input, char * argument, size_t maxLength)
{
bool status = true;
// maxLength gets 1 subtracted from it in the loop (to leave room for null-terminator)
// this will cause unsigned overflow it maxLength == 0
if (maxLength > 0 && validateCommandInputStartStatus(input))
{
size_t i = 0; // for comparison with maxLength, i should be unsigned type
char ch;
// Compare i with one less than maxLength to allow room for null terminator
while (i < maxLength - 1 &&
(ch = getCharFromInputString(input)) &&
!isspace(ch))
{
argument[i++] = ch;
}
// null-terminate the argument
argument[i] = 0;
seekToNextArgument(input, true);
}
else
{
status = false;
}
return status;
}
bool getUnsignedArgument(SudokuCommandInput * input, unsigned * argument)
{
bool status = true;
if (validateCommandInputStartStatus(input))
{
String numberCharacters = { 0 };
initializeString(&numberCharacters);
int ch;
while ((ch = getCharFromInputString(input)) && !isspace(ch) && isdigit(ch))
{
addCharToString(&numberCharacters, ch);
}
// convert the digit characters read into numeric form
// because we read only digits, number should never be negative
*argument = (unsigned)atoi(numberCharacters.array);
// NOTE: if conversion fails, *argument == 0
seekToNextArgument(input, true);
}
else
{
status = false;
}
return status;
}
/**
* returns the INTEGER value of the column, starting from 0, NOT the letter that was provided
*/
bool getColumnArgument(SudokuCommandInput * input, char *argument)
{
bool status = true;
if (validateCommandInputStartStatus(input))
{
*argument = getCharFromInputString(input);
// turn ASCII code into integer value
*argument = SUDOKU_COL_LETTER_TO_INDEX(*argument);
// is argument in range [0, 8] (inclusive)?
status = validateColIndex(*argument);
seekToNextArgument(input, false);
}
else
{
puts("No argument provided for column letter");
status = false;
}
return status;
}
bool getRowArgument(SudokuCommandInput * input, char * argument)
{
bool status = true;
if (validateCommandInputStartStatus(input))
{
*argument = getCharFromInputString(input);
// turn ASCII code into integer value
*argument = SUDOKU_ROW_NUMBER_TO_INDEX(*argument);
// is argument inside range [0, 8] (inclusive)?
status = validateRowIndex(*argument);
seekToNextArgument(input, false);
}
else
{
puts("No argument provided for row number");
status = false;
}
return status;
}
bool getSudokuDigitArgument(SudokuCommandInput * input, char * argument)
{
bool status = true;
if (validateCommandInputStartStatus(input))
{
*argument = getCharFromInputString(input);
// turn ASCII code into integer value
*argument = SUDOKU_DIGIT_CHAR_TO_VALUE(*argument);
// is argument in range [0, 9] (inclusive)?
status = validateSudokuDigit(*argument);
seekToNextArgument(input, false);
}
else
{
puts("No argument provided for new sudoku digit");
status = false;
}
return status;
}
void printCommands()
{
int i;
puts("Available commands:");
for (i = 0; i < SUDOKU_COMMAND_COUNT; ++i)
{
printf("'%s' \t(%s)\n", commands[i].name, commands[i].description);
}
}
const struct SudokuCommand *getCommand(SudokuCommandInput *input)
{
const struct SudokuCommand *command = NULL;
do
{
char commandName[SUDOKU_COMMAND_NAME_LENGTH_MAX];
clearString(&input->string);
input->currentIndex = 0;
ensureCleanInput();
fputs("Enter command: ", stdout);
readString(&input->string);
putchar('\n');
if (getStringArgument(input, commandName, SUDOKU_COMMAND_NAME_LENGTH_MAX))
{
command = matchCommand(commandName);
}
// command will be null if getCommandNameArgument failed OR if no match was found
if (!command)
{
printf("'%s' is not a valid command. \n%s\n\n", commandName, showAllCommandsPrompt);
}
} while (!command);
return command;
}
const struct SudokuCommand *matchCommand(char *name)
{
const struct SudokuCommand *command = NULL;
int i;
for (i = 0; !command && i < SUDOKU_COMMAND_COUNT; ++i)
{
if (strcmp(name, commands[i].name) == 0)
{
command = &commands[i];
}
}
return command;
}