/* * Functions: interactiveMode * Interactive Mode of Smiley Program. User are allowed to control * Smiley by entering mothed which on the list interactively. */ int interactiveMode(){ //output information printf("Next step for Smiley:\n"); printf("[1] move();\n"); printf("[2] turnLeft();\n"); printf("[3] putFlash();\n"); printf("[4] pickFlash();\n"); printf("[0] Exit Smiley.\n"); //let user choose int select=0; printf(">> "); while(scanf("%d",&select)!=1){ printf("Invalid input, please try again.\n"); } switch(select){ case 1: move(); break; case 2: turnLeft(); break; case 3: putFlash(); break; case 4: pickFlash(); break; case 0: return 0; break; default: printf("Invalid input, please try agin.\n"); interactiveMode(); } return 1; }
int main(int argc, char *argv[]) { // First check for special commands if (argc >= 2) { if (argv[1] == std::string("--help")) { printHelpMessage(std::cout, true); exit(EXIT_SUCCESS); } } // Enter interactive mode if less than one argument is provided // (the first argument is the name of the command) if (argc <= 1) { interactiveMode(); } else { // Join all arguments, ignoring spaces // EDIT: Ignore the first argument. Is value is 'bin/eval-test' std::string input = ""; for (int i = 1; i < argc; i++) { input += argv[i]; } commandLineMode(input); } }
int main(int argc, char **argv) { int isEnd; if(pipe(pdes)) { die("pipe()"); }; if(argc == 1) { // interactiveMode while(1) { isEnd = interactiveMode(); if(isEnd) { fputs("Exit MultiPShell..\n", stdout); break; } } } else if (argc == 2) { //isEnd = batchMode(argv[1]); isEnd = 0; if(isEnd) return 0; } else { fprintf(stderr, "Invalid commands.\nCheck your commands.\n"); } return 0; }
int main(int argc, char** argv) { if(argc > 1) return batchMode(argc, argv); else interactiveMode(); return 0; }