param_dump.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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", this->name);
  14. lub_dump_printf("text : %s\n", this->text);
  15. lub_dump_printf("value : %s\n", this->value);
  16. lub_dump_printf("ptype : %s\n", clish_ptype__get_name(this->ptype));
  17. lub_dump_printf("default : %s\n",
  18. this->defval ? this->defval : "(null)");
  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",
  36. this->optional ? "true" : "false");
  37. lub_dump_printf("hidden : %s\n",
  38. this->hidden ? "true" : "false");
  39. lub_dump_printf("test : %s\n", this->test);
  40. lub_dump_printf("completion : %s\n", this->completion);
  41. /* Get each parameter to dump their details */
  42. for (i = 0; i < clish_paramv__get_count(this->paramv); i++) {
  43. clish_param_dump(clish_param__get_param(this, i));
  44. }
  45. lub_dump_undent();
  46. }
  47. /*--------------------------------------------------------- */