cli_shared_methods.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <toolbox/cli/cli_command.h>
  3. #include <cli/cli_main_commands.h>
  4. #include <cli/cli_ansi.h>
  5. #include "../types/plugin_state.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /**
  10. * @brief Checks whether user is authenticated and entered correct PIN.
  11. * If user is not authenticated it prompts user to enter correct PIN to authenticate.
  12. * @param plugin_state application state
  13. * @param pipe pointer to the CLI pipe
  14. * @return \c true if user is already authenticated or successfully authenticated; \c false otherwise
  15. */
  16. bool totp_cli_ensure_authenticated(const PluginState* plugin_state, PipeSide* pipe);
  17. /**
  18. * @brief Forces application to be instantly closed
  19. * @param event_queue main app queue
  20. */
  21. void totp_cli_force_close_app(void* ctx);
  22. /**
  23. * @brief Reads line of characters from console
  24. * @param pipe pointer to the CLI pipe
  25. * @param out_str pointer to an output string to put read line to
  26. * @param mask_user_input whether to mask input characters in console or not
  27. * @return \c true if line successfully read and confirmed; \c false otherwise
  28. */
  29. bool totp_cli_read_line(PipeSide* pipe, FuriString* out_str, bool mask_user_input);
  30. /**
  31. * @brief Extracts \c uint8_t value and trims arguments string
  32. * @param args arguments string
  33. * @param[out] value parsed value
  34. * @return \c true if value successfully read and parsed as \c uint8_t ; \c false otherwise
  35. */
  36. bool args_read_uint8_and_trim(FuriString* args, uint8_t* value);
  37. /**
  38. * @brief Free \c FuriString instance in a secure manner by clearing it first
  39. * @param str instance to free
  40. */
  41. void furi_string_secure_free(FuriString* str);
  42. /**
  43. * @brief Prints information about unknown argument
  44. * @param arg
  45. */
  46. void totp_cli_printf_unknown_argument(const FuriString* arg);
  47. /**
  48. * @brief Prints information about missed required argument
  49. * @param arg
  50. */
  51. void totp_cli_printf_missed_argument_value(char* arg);
  52. #ifdef __cplusplus
  53. }
  54. #endif