help.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <flipper_application/flipper_application.h>
  2. #include <storage/storage.h>
  3. #include <toolbox/stream/stream.h>
  4. #include <toolbox/stream/file_stream.h>
  5. #include "../../cli_helpers.h"
  6. #include "../../cli_plugin_interface.h"
  7. static void handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
  8. UNUSED(args);
  9. UNUSED(cli);
  10. UNUSED(plugin_state);
  11. Storage* storage = furi_record_open(RECORD_STORAGE);
  12. Stream* stream = file_stream_alloc(storage);
  13. if(file_stream_open(
  14. stream, EXT_PATH("apps_assets/totp/cli/cli_help.txt"), FSAM_READ, FSOM_OPEN_EXISTING)) {
  15. uint8_t buffer[32U];
  16. size_t bytes_read;
  17. while((bytes_read = stream_read(stream, &buffer[0], sizeof(buffer))) > 0) {
  18. cli_write(cli, &buffer[0], bytes_read);
  19. }
  20. }
  21. file_stream_close(stream);
  22. stream_free(stream);
  23. furi_record_close(RECORD_STORAGE);
  24. }
  25. static const CliPlugin plugin = {.name = "TOTP CLI Plugin: Help", .handle = &handle};
  26. static const FlipperAppPluginDescriptor plugin_descriptor = {
  27. .appid = PLUGIN_APP_ID,
  28. .ep_api_version = PLUGIN_API_VERSION,
  29. .entry_point = &plugin,
  30. };
  31. const FlipperAppPluginDescriptor* totp_cli_help_plugin_ep() {
  32. return &plugin_descriptor;
  33. }