Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: nucleo_ucmd_helloworld
ucOpt.c
00001 #include "ucmd_internal.h" 00002 00003 const char *ucOpt_validation_err_invalid_argument_prefix = "Invalid argument: "; 00004 const char *ucOpt_validation_err_invalid_switch_prefix = "Invalid switch: "; 00005 const char *ucOpt_validation_err_invalid_switch_argument_prefix = "Invalid switch argument: "; 00006 00007 const char *ucOpt_get_name(ucOpt *p) { 00008 if (NULL == p) return NULL; 00009 return p->name; 00010 } 00011 00012 const char *ucOpt_get_desc(ucOpt *p) { 00013 if (NULL == p) return NULL; 00014 return p->desc; 00015 } 00016 00017 ucBool ucOpt_is_required(ucOpt *p) { 00018 if (NULL == p) return ucBool_FALSE; 00019 return p->is_required; 00020 } 00021 00022 void ucOpt_send_help(ucOpt *p, ucCmdLine *cmd, const char *prefix) { 00023 static const char *required_format = "%s%s: %s"; 00024 static const char *optional_format = "%s[%s]: %s"; 00025 ucCmdLine_respond(cmd, ucCmdLine_format_response( 00026 cmd, 00027 ucOpt_is_required(p) ? required_format : optional_format, 00028 prefix, 00029 ucOpt_get_name(p), 00030 ucOpt_get_desc(p) 00031 )); 00032 } 00033 00034 ucOpt *ucOpt_init(ucOpt *p, const char *name, const char *desc, ucBool is_required) { 00035 if (NULL == p) return NULL; 00036 p->name = name; 00037 p->desc = desc; 00038 p->is_required = is_required; 00039 return p; 00040 } 00041
Generated on Thu Jul 14 2022 20:04:57 by
1.7.2