param_dump.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifdef DEBUG
  2. /*
  3. * param_dump.c
  4. */
  5. #include "private.h"
  6. #include "lub/dump.h"
  7. /*--------------------------------------------------------- */
  8. void clish_param_dump(const clish_param_t * this)
  9. {
  10. unsigned i;
  11. char *mode;
  12. lub_dump_printf("param(%p)\n", this);
  13. lub_dump_indent();
  14. lub_dump_printf("name : %s\n", LUB_DUMP_STR(this->name));
  15. lub_dump_printf("text : %s\n", LUB_DUMP_STR(this->text));
  16. lub_dump_printf("value : %s\n", LUB_DUMP_STR(this->value));
  17. lub_dump_printf("ptype : %s\n", clish_ptype__get_name(this->ptype));
  18. lub_dump_printf("default : %s\n", LUB_DUMP_STR(this->defval));
  19. switch (this->mode) {
  20. case CLISH_PARAM_COMMON:
  21. mode = "COMMON";
  22. break;
  23. case CLISH_PARAM_SWITCH:
  24. mode = "SWITCH";
  25. break;
  26. case CLISH_PARAM_SUBCOMMAND:
  27. mode = "SUBCOMMAND";
  28. break;
  29. default:
  30. mode = "Unknown";
  31. break;
  32. }
  33. lub_dump_printf("mode : %s\n", mode);
  34. lub_dump_printf("paramc : %d\n", clish_paramv__get_count(this->paramv));
  35. lub_dump_printf("optional : %s\n", LUB_DUMP_BOOL(this->optional));
  36. lub_dump_printf("hidden : %s\n", LUB_DUMP_BOOL(this->hidden));
  37. lub_dump_printf("test : %s\n", LUB_DUMP_STR(this->test));
  38. lub_dump_printf("completion : %s\n", LUB_DUMP_STR(this->completion));
  39. /* Get each parameter to dump their details */
  40. for (i = 0; i < clish_paramv__get_count(this->paramv); i++) {
  41. clish_param_dump(clish_param__get_param(this, i));
  42. }
  43. lub_dump_undent();
  44. }
  45. /*--------------------------------------------------------- */
  46. #endif /* DEBUG */