Ignore:
Timestamp:
2010-11-25T13:42:50Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8df8415
Parents:
a93d79a (diff), eb667613 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/help/help.c

    ra93d79a r8fb1bf82  
    4545extern const char *progname;
    4646
    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
    5051
    5152volatile int mod_switch = -1;
     
    5556{
    5657        int rc = HELP_IS_RUBBISH;
     58
     59        if (str_cmp(cmd, "commands") == 0)
     60                return HELP_IS_COMMANDS;
    5761
    5862        rc = is_builtin(cmd);
     
    9094}
    9195
    92 int cmd_help(char *argv[])
     96static void help_commands(void)
    9397{
     98        builtin_t *cmd;
    9499        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;
    100101
    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");
    132103        printf("  ------------------------------------------------------------\n");
    133104
     
    154125        printf("\n  Try %s %s for more information on how `%s' works.\n\n",
    155126                cmdname, cmdname, cmdname);
     127}
     128
     129/** Display survival tips. ('help' without arguments) */
     130static 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
     156int 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();
    156196
    157197        return CMD_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.