Radek Krejci | e9f13b1 | 2020-11-09 17:42:04 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @file cmd.h |
| 3 | * @author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 5 | * @brief libyang's yanglint tool commands header |
| 6 | * |
| 7 | * Copyright (c) 2015-2020 CESNET, z.s.p.o. |
| 8 | * |
| 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * https://opensource.org/licenses/BSD-3-Clause |
| 14 | */ |
| 15 | |
| 16 | #ifndef COMMANDS_H_ |
| 17 | #define COMMANDS_H_ |
| 18 | |
| 19 | #include "libyang.h" |
| 20 | |
| 21 | /** |
| 22 | * @brief command information |
| 23 | */ |
| 24 | typedef struct { |
| 25 | char *name; /* User printable name of the function. */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 26 | |
Radek Krejci | e9f13b1 | 2020-11-09 17:42:04 +0100 | [diff] [blame] | 27 | void (*func)(struct ly_ctx **ctx, const char *); /* Function to call to do the command. */ |
| 28 | void (*help_func)(void); /* Display command help. */ |
| 29 | char *helpstring; /* Documentation for this function. */ |
aPiecek | 15cc4cf | 2023-04-17 15:23:21 +0200 | [diff] [blame^] | 30 | char *optstring; /* Option characters used in function getopt_long. */ |
Radek Krejci | e9f13b1 | 2020-11-09 17:42:04 +0100 | [diff] [blame] | 31 | } COMMAND; |
| 32 | |
| 33 | /** |
| 34 | * @brief The list of available commands. |
| 35 | */ |
| 36 | extern COMMAND commands[]; |
| 37 | |
aPiecek | 15cc4cf | 2023-04-17 15:23:21 +0200 | [diff] [blame^] | 38 | /** |
| 39 | * @brief Index for global variable ::commands. |
| 40 | */ |
| 41 | enum COMMAND_INDEX { |
| 42 | CMD_HELP = 0, |
| 43 | CMD_ADD, |
| 44 | CMD_LOAD, |
| 45 | CMD_PRINT, |
| 46 | CMD_DATA, |
| 47 | CMD_LIST, |
| 48 | CMD_FEATURE, |
| 49 | CMD_SEARCHPATH, |
| 50 | CMD_CLEAR, |
| 51 | CMD_VERB, |
| 52 | #ifndef NDEBUG |
| 53 | CMD_DEBUG, |
| 54 | #endif |
| 55 | }; |
| 56 | |
Radek Krejci | e9f13b1 | 2020-11-09 17:42:04 +0100 | [diff] [blame] | 57 | /* cmd_add.c */ |
| 58 | void cmd_add(struct ly_ctx **ctx, const char *cmdline); |
| 59 | void cmd_add_help(void); |
| 60 | |
| 61 | /* cmd_clear.c */ |
| 62 | void cmd_clear(struct ly_ctx **ctx, const char *cmdline); |
| 63 | void cmd_clear_help(void); |
| 64 | |
| 65 | /* cmd_data.c */ |
| 66 | void cmd_data(struct ly_ctx **ctx, const char *cmdline); |
| 67 | void cmd_data_help(void); |
| 68 | |
| 69 | /* cmd_list.c */ |
| 70 | void cmd_list(struct ly_ctx **ctx, const char *cmdline); |
| 71 | void cmd_list_help(void); |
| 72 | |
Michal Vasko | 538be42 | 2021-10-19 14:06:59 +0200 | [diff] [blame] | 73 | /* cmd_feature.c */ |
| 74 | void cmd_feature(struct ly_ctx **ctx, const char *cmdline); |
| 75 | void cmd_feature_help(void); |
| 76 | |
Radek Krejci | e9f13b1 | 2020-11-09 17:42:04 +0100 | [diff] [blame] | 77 | /* cmd_load.c */ |
| 78 | void cmd_load(struct ly_ctx **ctx, const char *cmdline); |
| 79 | void cmd_load_help(void); |
| 80 | |
| 81 | /* cmd_print.c */ |
| 82 | void cmd_print(struct ly_ctx **ctx, const char *cmdline); |
| 83 | void cmd_print_help(void); |
| 84 | |
| 85 | /* cmd_searchpath.c */ |
| 86 | void cmd_searchpath(struct ly_ctx **ctx, const char *cmdline); |
| 87 | void cmd_searchpath_help(void); |
| 88 | |
| 89 | #endif /* COMMANDS_H_ */ |