kcommand.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /** @file kcommand.h
  2. *
  3. * @brief Klish scheme's "command" entry
  4. */
  5. #ifndef _klish_kcommand_h
  6. #define _klish_kcommand_h
  7. #include <faux/list.h>
  8. #include <klish/kparam.h>
  9. #include <klish/kaction.h>
  10. typedef struct kcommand_s kcommand_t;
  11. typedef faux_list_node_t kcommand_params_node_t;
  12. typedef faux_list_node_t kcommand_actions_node_t;
  13. C_DECL_BEGIN
  14. kcommand_t *kcommand_new(const char *name);
  15. void kcommand_free(kcommand_t *command);
  16. const char *kcommand_name(const kcommand_t *command);
  17. const char *kcommand_help(const kcommand_t *command);
  18. bool_t kcommand_set_help(kcommand_t *command, const char *help);
  19. // PARAMs
  20. faux_list_t *kcommand_params(const kcommand_t *command);
  21. bool_t kcommand_add_param(kcommand_t *command, kparam_t *param);
  22. kparam_t *kcommand_find_param(const kcommand_t *command, const char *name);
  23. ssize_t kcommand_params_len(const kcommand_t *command);
  24. kcommand_params_node_t *kcommand_params_iter(const kcommand_t *command);
  25. kparam_t *kcommand_params_each(kcommand_params_node_t **iter);
  26. // ACTIONs
  27. faux_list_t *kcommand_actions(const kcommand_t *command);
  28. bool_t kcommand_add_action(kcommand_t *command, kaction_t *action);
  29. ssize_t kcommand_actions_len(const kcommand_t *command);
  30. kcommand_actions_node_t *kcommand_actions_iter(const kcommand_t *command);
  31. kaction_t *kcommand_actions_each(kcommand_actions_node_t **iter);
  32. C_DECL_END
  33. #endif // _klish_kcommand_h