cli_shared_methods.h 1.8 KB

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