blob: 5898cfeebdaf9d7658d53a6896a03ed74c46c262 [file] [log] [blame]
Radek Krejcie9f13b12020-11-09 17:42:04 +01001/**
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 */
24typedef struct {
25 char *name; /* User printable name of the function. */
Michal Vasko26bbb272022-08-02 14:54:33 +020026
Radek Krejcie9f13b12020-11-09 17:42:04 +010027 void (*func)(struct ly_ctx **ctx, const char *); /* Function to call to do the command. */
28 void (*help_func)(void); /* Display command help. */
aPiecek647f62e2023-05-18 10:55:58 +020029 void (*free_func)(void); /* Freeing global variables allocated by the command. */
Radek Krejcie9f13b12020-11-09 17:42:04 +010030 char *helpstring; /* Documentation for this function. */
aPiecek15cc4cf2023-04-17 15:23:21 +020031 char *optstring; /* Option characters used in function getopt_long. */
Radek Krejcie9f13b12020-11-09 17:42:04 +010032} COMMAND;
33
34/**
35 * @brief The list of available commands.
36 */
37extern COMMAND commands[];
38
aPiecek15cc4cf2023-04-17 15:23:21 +020039/**
40 * @brief Index for global variable ::commands.
41 */
42enum COMMAND_INDEX {
43 CMD_HELP = 0,
44 CMD_ADD,
45 CMD_LOAD,
46 CMD_PRINT,
47 CMD_DATA,
48 CMD_LIST,
49 CMD_FEATURE,
50 CMD_SEARCHPATH,
aPiecek647f62e2023-05-18 10:55:58 +020051 CMD_EXTDATA,
aPiecek15cc4cf2023-04-17 15:23:21 +020052 CMD_CLEAR,
53 CMD_VERB,
54#ifndef NDEBUG
55 CMD_DEBUG,
56#endif
57};
58
aPiecek647f62e2023-05-18 10:55:58 +020059/**
60 * @brief For each cmd, call the COMMAND.free_func in the variable 'commands'.
61 */
62void cmd_free(void);
63
Radek Krejcie9f13b12020-11-09 17:42:04 +010064/* cmd_add.c */
65void cmd_add(struct ly_ctx **ctx, const char *cmdline);
66void cmd_add_help(void);
67
68/* cmd_clear.c */
69void cmd_clear(struct ly_ctx **ctx, const char *cmdline);
70void cmd_clear_help(void);
71
72/* cmd_data.c */
73void cmd_data(struct ly_ctx **ctx, const char *cmdline);
74void cmd_data_help(void);
75
76/* cmd_list.c */
77void cmd_list(struct ly_ctx **ctx, const char *cmdline);
78void cmd_list_help(void);
79
Michal Vasko538be422021-10-19 14:06:59 +020080/* cmd_feature.c */
81void cmd_feature(struct ly_ctx **ctx, const char *cmdline);
82void cmd_feature_help(void);
83
Radek Krejcie9f13b12020-11-09 17:42:04 +010084/* cmd_load.c */
85void cmd_load(struct ly_ctx **ctx, const char *cmdline);
86void cmd_load_help(void);
87
88/* cmd_print.c */
89void cmd_print(struct ly_ctx **ctx, const char *cmdline);
90void cmd_print_help(void);
91
92/* cmd_searchpath.c */
93void cmd_searchpath(struct ly_ctx **ctx, const char *cmdline);
94void cmd_searchpath_help(void);
95
aPiecek647f62e2023-05-18 10:55:58 +020096/* cmd_extdata.c */
97void cmd_extdata(struct ly_ctx **ctx, const char *cmdline);
98void cmd_extdata_help(void);
99void cmd_extdata_free(void);
100
Radek Krejcie9f13b12020-11-09 17:42:04 +0100101#endif /* COMMANDS_H_ */