param_dump.c 1.5 KB

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