Skip to content

Commit cd5cd64

Browse files
authored
Implemented #188 (#189)
1 parent 2593677 commit cd5cd64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+242
-68
lines changed

application.fam

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ App(
5151
"wolfcrypt/src/sha256.c",
5252
"wolfcrypt/src/sha512.c"
5353
],
54-
cflags=["-Wno-error", "-include${FAP_SRC_DIR}/wolfssl_config.h"]
54+
cflags=["-Wno-error"],
55+
cdefines=["HAVE_CONFIG_H"],
56+
cincludes=["config/wolfssl"]
5557
),
5658
],
5759
)

cli/commands/add/add.c

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static TotpIteratorUpdateTokenResult
7979
return TotpIteratorUpdateTokenResultSuccess;
8080
}
8181

82+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
8283
void totp_cli_command_add_docopt_commands() {
8384
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_ADD ", " TOTP_CLI_COMMAND_ADD_ALT
8485
", " TOTP_CLI_COMMAND_ADD_ALT2 " Add new token\r\n");
@@ -155,6 +156,7 @@ void totp_cli_command_add_docopt_options() {
155156
TOTP_CLI_PRINTF(" # " TOKEN_AUTOMATION_FEATURE_TYPE_SLOWER_NAME
156157
" - Type slower\r\n");
157158
}
159+
#endif
158160

159161
void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
160162
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {

cli/commands/add/add.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#pragma once
22

33
#include <cli/cli.h>
4+
#include "../../../config/app/config.h"
45
#include "../../../types/plugin_state.h"
56

67
#define TOTP_CLI_COMMAND_ADD "add"
78
#define TOTP_CLI_COMMAND_ADD_ALT "mk"
89
#define TOTP_CLI_COMMAND_ADD_ALT2 "new"
910

1011
void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
12+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1113
void totp_cli_command_add_docopt_commands();
1214
void totp_cli_command_add_docopt_usage();
1315
void totp_cli_command_add_docopt_arguments();
14-
void totp_cli_command_add_docopt_options();
16+
void totp_cli_command_add_docopt_options();
17+
#endif

cli/commands/automation/automation.c

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT_PREFIX "-k"
1616
#define TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT "layout"
1717

18+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1819
void totp_cli_command_automation_docopt_commands() {
1920
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_AUTOMATION " Get or set automation settings\r\n");
2021
}
@@ -45,6 +46,7 @@ void totp_cli_command_automation_docopt_options() {
4546
", " TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY
4647
"\r\n");
4748
}
49+
#endif
4850

4951
static void print_method(AutomationMethod method, const char* color) {
5052
#ifdef TOTP_BADBT_AUTOMATION_ENABLED

cli/commands/automation/automation.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_AUTOMATION "automation"
78

89
void totp_cli_command_automation_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
10+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
911
void totp_cli_command_automation_docopt_commands();
1012
void totp_cli_command_automation_docopt_usage();
1113
void totp_cli_command_automation_docopt_arguments();
12-
void totp_cli_command_automation_docopt_options();
14+
void totp_cli_command_automation_docopt_options();
15+
#endif

cli/commands/delete/delete.c

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#define TOTP_CLI_COMMAND_DELETE_ARG_FORCE_PREFIX "-f"
1212

13+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1314
void totp_cli_command_delete_docopt_commands() {
1415
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_DELETE ", " TOTP_CLI_COMMAND_DELETE_ALT
1516
" Delete existing token\r\n");
@@ -30,6 +31,7 @@ void totp_cli_command_delete_docopt_options() {
3031
TOTP_CLI_PRINTF(" " DOCOPT_SWITCH(
3132
TOTP_CLI_COMMAND_DELETE_ARG_FORCE_PREFIX) " Force command to do not ask user for interactive confirmation\r\n");
3233
}
34+
#endif
3335

3436
void totp_cli_command_delete_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
3537
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {

cli/commands/delete/delete.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_DELETE "delete"
78
#define TOTP_CLI_COMMAND_DELETE_ALT "rm"
89

910
void totp_cli_command_delete_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
11+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1012
void totp_cli_command_delete_docopt_commands();
1113
void totp_cli_command_delete_docopt_usage();
1214
void totp_cli_command_delete_docopt_arguments();
13-
void totp_cli_command_delete_docopt_options();
15+
void totp_cli_command_delete_docopt_options();
16+
#endif

cli/commands/details/details.c

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static void print_automation_features(const TokenInfo* token_info) {
3737
}
3838
}
3939

40+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
4041
void totp_cli_command_details_docopt_commands() {
4142
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_DETAILS ", " TOTP_CLI_COMMAND_DETAILS_ALT
4243
" Displays token details\r\n");
@@ -47,6 +48,7 @@ void totp_cli_command_details_docopt_usage() {
4748
TOTP_CLI_COMMAND_DETAILS
4849
" | " TOTP_CLI_COMMAND_DETAILS_ALT) " " DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ARG_INDEX) "\r\n");
4950
}
51+
#endif
5052

5153
void totp_cli_command_details_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
5254
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {

cli/commands/details/details.h

+3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_DETAILS "lsattr"
78
#define TOTP_CLI_COMMAND_DETAILS_ALT "cat"
89

910
void totp_cli_command_details_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
11+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1012
void totp_cli_command_details_docopt_commands();
1113
void totp_cli_command_details_docopt_usage();
14+
#endif

cli/commands/help/help.c

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "../automation/automation.h"
1313
#include "../details/details.h"
1414

15+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1516
void totp_cli_command_help_docopt_commands() {
1617
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_HELP ", " TOTP_CLI_COMMAND_HELP_ALT
1718
", " TOTP_CLI_COMMAND_HELP_ALT2 " Show command usage help\r\n");
@@ -22,8 +23,10 @@ void totp_cli_command_help_docopt_usage() {
2223
TOTP_CLI_COMMAND_HELP " | " TOTP_CLI_COMMAND_HELP_ALT
2324
" | " TOTP_CLI_COMMAND_HELP_ALT2) "\r\n");
2425
}
26+
#endif
2527

2628
void totp_cli_command_help_handle() {
29+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
2730
TOTP_CLI_PRINTF("Usage:\r\n");
2831
totp_cli_command_help_docopt_usage();
2932
totp_cli_command_list_docopt_usage();
@@ -66,4 +69,8 @@ void totp_cli_command_help_handle() {
6669
totp_cli_command_delete_docopt_options();
6770
totp_cli_command_pin_docopt_options();
6871
totp_cli_command_automation_docopt_options();
72+
#else
73+
TOTP_CLI_PRINTF(
74+
"All the TOTP CLI commands, their arguments, options and usage can be found here https://t.ly/_6pJG");
75+
#endif
6976
}

cli/commands/help/help.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#pragma once
22

3+
#include "../../../config/app/config.h"
34
#include <cli/cli.h>
45

56
#define TOTP_CLI_COMMAND_HELP "help"
67
#define TOTP_CLI_COMMAND_HELP_ALT "h"
78
#define TOTP_CLI_COMMAND_HELP_ALT2 "?"
89

910
void totp_cli_command_help_handle();
11+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1012
void totp_cli_command_help_docopt_commands();
11-
void totp_cli_command_help_docopt_usage();
13+
void totp_cli_command_help_docopt_usage();
14+
#endif

cli/commands/list/list.c

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "../../../ui/scene_director.h"
77
#include "../../cli_helpers.h"
88

9+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
910
void totp_cli_command_list_docopt_commands() {
1011
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_LIST ", " TOTP_CLI_COMMAND_LIST_ALT
1112
" List all available tokens\r\n");
@@ -15,6 +16,7 @@ void totp_cli_command_list_docopt_usage() {
1516
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED(
1617
TOTP_CLI_COMMAND_LIST " | " TOTP_CLI_COMMAND_LIST_ALT) "\r\n");
1718
}
19+
#endif
1820

1921
void totp_cli_command_list_handle(PluginState* plugin_state, Cli* cli) {
2022
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {

cli/commands/list/list.h

+3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_LIST "list"
78
#define TOTP_CLI_COMMAND_LIST_ALT "ls"
89

910
void totp_cli_command_list_handle(PluginState* plugin_state, Cli* cli);
11+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1012
void totp_cli_command_list_docopt_commands();
1113
void totp_cli_command_list_docopt_usage();
14+
#endif

cli/commands/move/move.c

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#define TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX "new_index"
1212

13+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1314
void totp_cli_command_move_docopt_commands() {
1415
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_MOVE ", " TOTP_CLI_COMMAND_MOVE_ALT
1516
" Move token\r\n");
@@ -26,6 +27,7 @@ void totp_cli_command_move_docopt_arguments() {
2627
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_MOVE_ARG_NEW_INDEX
2728
" New token index in the list\r\n");
2829
}
30+
#endif
2931

3032
void totp_cli_command_move_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
3133
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {

cli/commands/move/move.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_MOVE "move"
78
#define TOTP_CLI_COMMAND_MOVE_ALT "mv"
89

910
void totp_cli_command_move_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
11+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1012
void totp_cli_command_move_docopt_commands();
1113
void totp_cli_command_move_docopt_usage();
12-
void totp_cli_command_move_docopt_arguments();
14+
void totp_cli_command_move_docopt_arguments();
15+
#endif

cli/commands/notification/notification.c

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define TOTP_CLI_COMMAND_NOTIFICATION_METHOD_SOUND "sound"
1010
#define TOTP_CLI_COMMAND_NOTIFICATION_METHOD_VIBRO "vibro"
1111

12+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1213
void totp_cli_command_notification_docopt_commands() {
1314
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NOTIFICATION
1415
" Get or set notification method\r\n");
@@ -27,6 +28,7 @@ void totp_cli_command_notification_docopt_arguments() {
2728
", " TOTP_CLI_COMMAND_NOTIFICATION_METHOD_SOUND
2829
", " TOTP_CLI_COMMAND_NOTIFICATION_METHOD_VIBRO "\r\n");
2930
}
31+
#endif
3032

3133
static void
3234
totp_cli_command_notification_print_method(NotificationMethod method, const char* color) {

cli/commands/notification/notification.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_NOTIFICATION "notify"
78

89
void totp_cli_command_notification_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
10+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
911
void totp_cli_command_notification_docopt_commands();
1012
void totp_cli_command_notification_docopt_usage();
11-
void totp_cli_command_notification_docopt_arguments();
13+
void totp_cli_command_notification_docopt_arguments();
14+
#endif

cli/commands/pin/pin.c

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT_PREFIX "-c"
1616
#define TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT "slot"
1717

18+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1819
void totp_cli_command_pin_docopt_commands() {
1920
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_PIN " Set\\change\\remove PIN\r\n");
2021
}
@@ -37,6 +38,7 @@ void totp_cli_command_pin_docopt_options() {
3738
ACCEPTABLE_CRYPTO_KEY_SLOT_START,
3839
ACCEPTABLE_CRYPTO_KEY_SLOT_END);
3940
}
41+
#endif
4042

4143
static inline uint8_t totp_cli_key_to_pin_code(uint8_t key) {
4244
uint8_t code = 0;

cli/commands/pin/pin.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_PIN "pin"
78

89
void totp_cli_command_pin_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
10+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
911
void totp_cli_command_pin_docopt_commands();
1012
void totp_cli_command_pin_docopt_usage();
11-
void totp_cli_command_pin_docopt_options();
13+
void totp_cli_command_pin_docopt_options();
14+
#endif

cli/commands/reset/reset.c

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#define TOTP_CLI_RESET_CONFIRMATION_KEYWORD "YES"
1010

11+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1112
void totp_cli_command_reset_docopt_commands() {
1213
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_RESET
1314
" Reset application to default settings\r\n");
@@ -16,6 +17,7 @@ void totp_cli_command_reset_docopt_commands() {
1617
void totp_cli_command_reset_docopt_usage() {
1718
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_RESET "\r\n");
1819
}
20+
#endif
1921

2022
void totp_cli_command_reset_handle(PluginState* plugin_state, Cli* cli) {
2123
TOTP_CLI_LOCK_UI(plugin_state);

cli/commands/reset/reset.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_RESET "reset"
78

89
void totp_cli_command_reset_handle(PluginState* plugin_state, Cli* cli);
10+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
911
void totp_cli_command_reset_docopt_commands();
10-
void totp_cli_command_reset_docopt_usage();
12+
void totp_cli_command_reset_docopt_usage();
13+
#endif

cli/commands/timezone/timezone.c

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#define TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE "timezone"
88

9+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
910
void totp_cli_command_timezone_docopt_commands() {
1011
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_TIMEZONE ", " TOTP_CLI_COMMAND_TIMEZONE_ALT
1112
" Get or set current timezone\r\n");
@@ -22,6 +23,7 @@ void totp_cli_command_timezone_docopt_arguments() {
2223
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE
2324
" Timezone offset in hours to be set\r\n");
2425
}
26+
#endif
2527

2628
void totp_cli_command_timezone_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
2729
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {

cli/commands/timezone/timezone.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
#include <cli/cli.h>
44
#include "../../../types/plugin_state.h"
5+
#include "../../../config/app/config.h"
56

67
#define TOTP_CLI_COMMAND_TIMEZONE "timezone"
78
#define TOTP_CLI_COMMAND_TIMEZONE_ALT "tz"
89

910
void totp_cli_command_timezone_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
11+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1012
void totp_cli_command_timezone_docopt_commands();
1113
void totp_cli_command_timezone_docopt_usage();
12-
void totp_cli_command_timezone_docopt_arguments();
14+
void totp_cli_command_timezone_docopt_arguments();
15+
#endif

0 commit comments

Comments
 (0)