cli_helpers.h 1.1 KB

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include <cli/cli.h>
  3. #include "../../types/plugin_state.h"
  4. #define TOTP_CLI_COMMAND_NAME "totp"
  5. #define DOCOPT_ARGUMENT(arg) "<" arg ">"
  6. #define DOCOPT_OPTIONAL(param) "[" param "]"
  7. #define DOCOPT_REQUIRED(param) "(" param ")"
  8. #define DOCOPT_OPTION(option, value) option " " value
  9. #define DOCOPT_SWITCH(option) option
  10. #define DOCOPT_OPTIONS "[options]"
  11. #define DOCOPT_DEFAULT(val) "[default: " val "]"
  12. #define TOTP_CLI_PRINTF(format, ...) \
  13. _Pragma(STRINGIFY(GCC diagnostic push)); \
  14. _Pragma(STRINGIFY(GCC diagnostic ignored "-Wdouble-promotion")); \
  15. printf(format, ##__VA_ARGS__); \
  16. _Pragma(STRINGIFY(GCC diagnostic pop));
  17. #define TOTP_CLI_DELETE_LAST_LINE() TOTP_CLI_PRINTF("\033[A\33[2K\r")
  18. #define TOTP_CLI_DELETE_CURRENT_LINE() TOTP_CLI_PRINTF("\33[2K\r")
  19. #define TOTP_CLI_PRINT_INVALID_ARGUMENTS() \
  20. TOTP_CLI_PRINTF( \
  21. "Invalid command arguments. use \"help\" command to get list of available commands")
  22. bool totp_cli_ensure_authenticated(PluginState* plugin_state, Cli* cli);