1 #include <stdio.h> 2 #include <string.h> 3 4 /* user defined headers */ 5 #include <common-cmds.h> 6 7 #include <kvm/util.h> 8 #include <kvm/kvm-help.h> 9 10 11 const char kvm_usage_string[] = 12 "kvm [--version] [--help] COMMAND [ARGS]"; 13 14 const char kvm_more_info_string[] = 15 "See 'kvm help COMMAND' for more information on a specific command."; 16 17 18 static void list_common_cmds_help(void) 19 { 20 unsigned int i, longest = 0; 21 22 for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { 23 if (longest < strlen(common_cmds[i].name)) 24 longest = strlen(common_cmds[i].name); 25 } 26 27 puts(" The most commonly used kvm commands are:"); 28 for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { 29 printf(" %-*s ", longest, common_cmds[i].name); 30 puts(common_cmds[i].help); 31 } 32 } 33 34 int kvm_cmd_help(int argc, const char **argv, const char *prefix) 35 { 36 if (!argv || !*argv) { 37 printf("\n usage: %s\n\n", kvm_usage_string); 38 list_common_cmds_help(); 39 printf("\n %s\n\n", kvm_more_info_string); 40 return 0; 41 } 42 return 0; 43 } 44