Changes in uspace/app/bdsh/cmds/modules/help/help.c [19f857a:4deb8b5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/help/help.c
r19f857a r4deb8b5 45 45 extern const char *progname; 46 46 47 #define HELP_IS_MODULE 1 48 #define HELP_IS_BUILTIN 0 49 #define HELP_IS_RUBBISH -1 47 #define HELP_IS_COMMANDS 2 48 #define HELP_IS_MODULE 1 49 #define HELP_IS_BUILTIN 0 50 #define HELP_IS_RUBBISH -1 50 51 51 52 volatile int mod_switch = -1; … … 55 56 { 56 57 int rc = HELP_IS_RUBBISH; 58 59 if (str_cmp(cmd, "commands") == 0) 60 return HELP_IS_COMMANDS; 57 61 58 62 rc = is_builtin(cmd); … … 90 94 } 91 95 92 int cmd_help(char *argv[])96 static void help_commands(void) 93 97 { 98 builtin_t *cmd; 94 99 module_t *mod; 95 builtin_t *cmd; 96 unsigned int i = 0; 97 int rc = 0; 98 int argc; 99 int level = HELP_SHORT; 100 unsigned int i; 100 101 101 argc = cli_count_args(argv); 102 103 if (argc > 3) { 104 printf("\nToo many arguments to `%s', try:\n", cmdname); 105 help_cmd_help(HELP_SHORT); 106 return CMD_FAILURE; 107 } 108 109 if (argc == 3) { 110 if (!str_cmp("extended", argv[2])) 111 level = HELP_LONG; 112 else 113 level = HELP_SHORT; 114 } 115 116 if (argc > 1) { 117 rc = is_mod_or_builtin(argv[1]); 118 switch (rc) { 119 case HELP_IS_RUBBISH: 120 printf("Invalid command %s\n", argv[1]); 121 return CMD_FAILURE; 122 case HELP_IS_MODULE: 123 help_module(mod_switch, level); 124 return CMD_SUCCESS; 125 case HELP_IS_BUILTIN: 126 help_builtin(mod_switch, level); 127 return CMD_SUCCESS; 128 } 129 } 130 131 printf("\n Available commands are:\n"); 102 printf("\n Bdsh built-in commands:\n"); 132 103 printf(" ------------------------------------------------------------\n"); 133 104 … … 154 125 printf("\n Try %s %s for more information on how `%s' works.\n\n", 155 126 cmdname, cmdname, cmdname); 127 } 128 129 /** Display survival tips. ('help' without arguments) */ 130 static void help_survival(void) 131 { 132 printf("Don't panic!\n\n"); 133 134 printf("This is Bdsh, the Brain dead shell, currently " 135 "the primary user interface to HelenOS. Bdsh allows you to enter " 136 "commands and supports history (Up, Down arrow keys), " 137 "line editing (Left Arrow, Right Arrow, Home, End, Backspace), " 138 "selection (Shift + movement keys), copy and paste (Ctrl-C, " 139 "Ctrl-V), similar to common desktop environments.\n\n"); 140 141 printf("The most basic filesystem commands are Bdsh builtins. Type " 142 "'help commands' [Enter] to see the list of Bdsh builtin commands. " 143 "Other commands are external executables located in the /app and " 144 "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] " 145 "to see their list. You can execute an external command simply " 146 "by entering its name (e.g. type 'tetris' [Enter]).\n\n"); 147 148 printf("HelenOS has virtual consoles (VCs). You can switch between " 149 "these using the F1-F11 keys.\n\n"); 150 151 printf("This is but a small glimpse of what you can do with HelenOS. " 152 "To learn more please point your browser to the HelenOS User's " 153 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n"); 154 } 155 156 int cmd_help(char *argv[]) 157 { 158 int rc = 0; 159 int argc; 160 int level = HELP_SHORT; 161 162 argc = cli_count_args(argv); 163 164 if (argc > 3) { 165 printf("\nToo many arguments to `%s', try:\n", cmdname); 166 help_cmd_help(HELP_SHORT); 167 return CMD_FAILURE; 168 } 169 170 if (argc == 3) { 171 if (!str_cmp("extended", argv[2])) 172 level = HELP_LONG; 173 else 174 level = HELP_SHORT; 175 } 176 177 if (argc > 1) { 178 rc = is_mod_or_builtin(argv[1]); 179 switch (rc) { 180 case HELP_IS_RUBBISH: 181 printf("Invalid topic %s\n", argv[1]); 182 return CMD_FAILURE; 183 case HELP_IS_COMMANDS: 184 help_commands(); 185 return CMD_SUCCESS; 186 case HELP_IS_MODULE: 187 help_module(mod_switch, level); 188 return CMD_SUCCESS; 189 case HELP_IS_BUILTIN: 190 help_builtin(mod_switch, level); 191 return CMD_SUCCESS; 192 } 193 } 194 195 help_survival(); 156 196 157 197 return CMD_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.