|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2013-2016 Damien P. George |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | + |
| 27 | +#include <stdio.h> |
| 28 | + |
| 29 | +#include "lib/utils/pyhelp.h" |
| 30 | + |
| 31 | +STATIC const char *help_text = |
| 32 | +"Welcome to MicroPython!\n" |
| 33 | +"\n" |
| 34 | +"Control commands:\n" |
| 35 | +" CTRL-A -- on a blank line, enter raw REPL mode\n" |
| 36 | +" CTRL-B -- on a blank line, enter normal REPL mode\n" |
| 37 | +" CTRL-C -- interrupt a running program\n" |
| 38 | +" CTRL-D -- on a blank line, do a soft reset of the board\n" |
| 39 | +" CTRL-E -- on a blank line, enter paste mode\n" |
| 40 | +"\n" |
| 41 | +"For further help on a specific object, type help(obj)\n" |
| 42 | +; |
| 43 | + |
| 44 | +STATIC mp_obj_t builtin_help(uint n_args, const mp_obj_t *args) { |
| 45 | + if (n_args == 0) { |
| 46 | + // print a general help message |
| 47 | + printf("%s", help_text); |
| 48 | + |
| 49 | + } else { |
| 50 | + // try to print something sensible about the given object |
| 51 | + pyhelp_print_obj(args[0]); |
| 52 | + } |
| 53 | + |
| 54 | + return mp_const_none; |
| 55 | +} |
| 56 | +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj, 0, 1, builtin_help); |
0 commit comments