Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tools/lint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ set(lintsrc
cmd_help.c
cmd_verb.c
cmd_debug.c
cmd_sample.c
cmd_ietf.c
yl_opt.c
yl_schema_features.c
common.c
Expand Down
8 changes: 8 additions & 0 deletions tools/lint/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ COMMAND commands[] = {
"data", cmd_data_opt, cmd_data_dep, cmd_data_store, cmd_data_process, cmd_data_help, NULL,
"Load, validate and optionally print instance data", "d:ef:F:hmo:O:R:r:nt:x:k:"
},
{
"sample", cmd_sample_opt, cmd_sample_dep, cmd_sample_exec, NULL, cmd_sample_help, NULL,
"Generate a sample data skeleton for a module", "f:ho:"
},
{
"list", cmd_list_opt, cmd_list_dep, cmd_list_exec, NULL, cmd_list_help, NULL,
"List all the loaded modules", "f:h"
Expand Down Expand Up @@ -104,6 +108,10 @@ COMMAND commands[] = {
"Unsupported for the Release build", "h"
#endif
},
{
"ietf", cmd_ietf_opt, cmd_ietf_dep, cmd_ietf_exec, NULL, cmd_ietf_help, NULL,
"Validate a loaded schema module according to IETF rules", "ho:"
},
{"quit", NULL, NULL, cmd_quit_exec, NULL, NULL, NULL, "Quit the program", "h"},
/* synonyms for previous commands */
{"?", NULL, NULL, cmd_help_exec, NULL, NULL, NULL, "Display commands description", "h"},
Expand Down
43 changes: 43 additions & 0 deletions tools/lint/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,27 @@ int cmd_print_dep(struct yl_opt *yo, int posc);
int cmd_print_exec(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv);
void cmd_print_help(void);

/* cmd_sample.c */

/**
* @copydoc cmd_add_opt
*/
int cmd_sample_opt(struct yl_opt *yo, const char *cmdline, char ***posv, int *posc);
/**
* @copydoc cmd_add_dep
*/
int cmd_sample_dep(struct yl_opt *yo, int posc);
void cmd_sample_help(void);
/**
Comment on lines +289 to +290

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a new line.

* @brief Print a sample skeleton of module in json or xml.
*
* @param[in,out] ctx context for libyang.
* @param[in] yo context for yanglint.
* @param[in] posv Name of the module to be printed.
* @return 0 on success, 1 on failure.
*/
int cmd_sample_exec(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv);

/* cmd_searchpath.c */

/**
Expand Down Expand Up @@ -391,4 +412,26 @@ int cmd_debug_store(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv);
int cmd_debug_setlog(struct ly_ctx *ctx, struct yl_opt *yo);
void cmd_debug_help(void);

/* cmd_ietf.c */
/**
* @copydoc cmd_add_opt
*/
int cmd_ietf_opt(struct yl_opt *yo, const char *cmdline, char ***posv, int *posc);
/**
* @copydoc cmd_add_dep

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a new line.

*/
int cmd_ietf_dep(struct yl_opt *yo, int posc);
void cmd_ietf_help(void);

/**
* @brief Execution handler for the 'ietf' command in the yanglint CLI tool.
*
* @param[in,out] ctx A double pointer to the libyang context containing the loaded modules.
* @param[in,out] yo A pointer to the yanglint options structure, which manages global
* @param[in] posv The positional command-line argument provided by the user, representing the target module name (e.g., "ietf-interfaces" or "ietf-interfaces@2014-05-08").
* @return 0 on successful execution of the validation pipeline (note: this returns 0 even if IETF compliance warnings/errors were printed to the output).
* @return 1 on fatal execution errors (e.g., module not found, module failed to compile, or memory allocation failure).
*/
int cmd_ietf_exec(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv);

#endif /* COMMANDS_H_ */
2 changes: 1 addition & 1 deletion tools/lint/cmd_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ store_parsed_module(const char *filepath, struct lys_module *mod, struct yl_opt
{
assert(!yo->interactive);

if (yo->schema_out_format || yo->feature_param_format) {
if (yo->schema_out_format || yo->feature_param_format || yo->data_out_format || yo->ietf_validation) {
if (ly_set_add(&yo->schema_modules, (void *)mod, 1, NULL)) {
YLMSG_E("Storing parsed schema module (%s) for print failed.", filepath);
return 1;
Expand Down
Loading