Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | ;;; cli-cmd-skel.el - cli command skeleton |
| 2 | |
| 3 | (require 'skeleton) |
| 4 | |
Keith Burns (alagalah) | ca46d8c | 2016-03-18 07:22:15 -0700 | [diff] [blame] | 5 | (define-skeleton skel-cli-cmd |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 6 | "Insert a CLI command " |
| 7 | nil |
| 8 | '(setq cmd-name (skeleton-read "Command Name: ")) |
| 9 | '(setq path (skeleton-read "Path: ")) |
| 10 | |
| 11 | " |
| 12 | static clib_error_t * |
| 13 | " cmd-name "_command_fn (vlib_main_t * vm, |
| 14 | unformat_input_t * input, |
| 15 | vlib_cli_command_t * cmd) |
| 16 | { |
| 17 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { |
| 18 | if (unformat (input, \"whatever %d\", &whatever)) |
| 19 | ; |
| 20 | else |
| 21 | return clib_error_return (0, \"unknown input `%U'\", |
| 22 | format_unformat_error, input); |
| 23 | } |
| 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | VLIB_CLI_COMMAND (" cmd-name "_command, static) = { |
| 28 | .path = \"" path "\", |
| 29 | .short_help = \"" path "\", |
| 30 | .function = " cmd-name "_command_fn, |
| 31 | }; |
| 32 | ") |