This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement struct `ta_cli_argument_s` for saving information of instructions. `ta_cli_arg_value_t` is an enum for recognising the commands. And once calling the function `ta_usage()`, it will show all the currently available command.
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "message.h" | ||
#include "stdio.h" | ||
|
||
void ta_usage() { | ||
printf("tangle-accelerator usage:\n"); | ||
for (int i = 0; i < cli_cmd_num; i++) { | ||
printf("--%-34s ", ta_cli_arguments_g[i].name); | ||
printf(" "); | ||
if (ta_cli_arguments_g[i].has_arg == REQUIRED_ARG) { | ||
printf(" arg "); | ||
} else if (ta_cli_arguments_g[i].has_arg == OPTIONAL_ARG) { | ||
printf("[arg]"); | ||
} else { | ||
printf(" "); | ||
} | ||
printf(" %s \n", ta_cli_arguments_g[i].desc); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef ACCELERATOR_MESSAGE_H_ | ||
#define ACCELERATOR_MESSAGE_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef enum ta_cli_arg_value_e { | ||
HELP_CLI, | ||
|
||
/** TA */ | ||
TA_HOST_CLI, | ||
TA_PORT_CLI, | ||
TA_THREAD_COUNT_CLI, | ||
TA_VERSION_CLI, | ||
|
||
/** IRI */ | ||
IRI_HOST_CLI, | ||
IRI_PORT_CLI, | ||
|
||
/** REDIS */ | ||
REDIS_HOST_CLI, | ||
REDIS_PORT_CLI, | ||
|
||
/** CONFIG */ | ||
MILESTONE_DEPTH_CLI, | ||
MWM_CLI, | ||
SEED_CLI, | ||
} ta_cli_arg_value_t; | ||
|
||
typedef enum ta_cli_arg_requirement_e { | ||
NO_ARG, | ||
REQUIRED_ARG, | ||
OPTIONAL_ARG | ||
} ta_cli_arg_requirement_t; | ||
|
||
static struct ta_cli_argument_s { | ||
char* name; | ||
int val; | ||
char* desc; | ||
ta_cli_arg_requirement_t has_arg; | ||
} ta_cli_arguments_g[] = { | ||
{"ta-help", HELP_CLI, "Show tangle-accelerator usage.", NO_ARG}}; | ||
|
||
static const int cli_cmd_num = | ||
sizeof(ta_cli_arguments_g) / sizeof(struct ta_cli_argument_s); | ||
void ta_usage(); | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // ACCELERATOR_MESSAGE_H_ |