Blame tools/re/yangre.1

Packit 8fb591
.\" Manpage for yanglint.
Packit 8fb591
.\" Process this file with
Packit 8fb591
.\" groff -man -Tascii yangre.1
Packit 8fb591
.\"
Packit 8fb591
Packit 8fb591
.TH YANGRE 1 "2018-11-09" "libyang"
Packit 8fb591
.SH NAME
Packit 8fb591
yangre \- YANG regular expression processor
Packit 8fb591
.
Packit 8fb591
.SH SYNOPSIS
Packit 8fb591
.B yangre
Packit 8fb591
[\-V] \-p \fIREGEXP\fP [\-i] [\-p \fIREGEXP\fP [\-i]...] \fISTRING\fP
Packit 8fb591
.br
Packit 8fb591
.B yangre
Packit 8fb591
[\-V] \-f \fIFILE\fP
Packit 8fb591
.
Packit 8fb591
.SH DESCRIPTION
Packit 8fb591
\fByangre\fP is a command-line tool to test and evaluate regular expressions
Packit 8fb591
for use in YANG schemas.  Supported regular expressions are defined by the
Packit 8fb591
W3C's XML-Schema standard.
Packit 8fb591
Packit 8fb591
\fByangre\fP can be used either with regular expressions and a target string
Packit 8fb591
on the command line or with input from a file.  The latter is particularly
Packit 8fb591
useful to avoid dealing with proper shell escaping of regular expression
Packit 8fb591
patterns, which can be somewhat tricky.
Packit 8fb591
.
Packit 8fb591
.SH GENERAL OPTIONS
Packit 8fb591
.TP
Packit 8fb591
.BR "\-h\fR,\fP \-\^\-help"
Packit 8fb591
.br
Packit 8fb591
Outputs usage help and exits.
Packit 8fb591
.TP
Packit 8fb591
.BR "\-v\fR,\fP \-\^\-version"
Packit 8fb591
.br
Packit 8fb591
Outputs the version number and exits.
Packit 8fb591
.TP
Packit 8fb591
.BR "\-V\fR,\fP \-\^\-verbose"
Packit 8fb591
Increases the verbosity level. If not specified, only errors are printed, with
Packit 8fb591
each appearance it adds: warnings, verbose messages, debug messages (if compiled
Packit 8fb591
with debug information).
Packit 8fb591
.SH COMMAND LINE INPUT
Packit 8fb591
.TP
Packit 8fb591
.BR "\-p \fIREGEXP\fP\fR,\fP \-\^\-pattern=\fIREGEXP\fP"
Packit 8fb591
.br
Packit 8fb591
One or more regular expression patterns to be tested against the input
Packit 8fb591
string.  Supplied expressions are tested in the order they appear on the
Packit 8fb591
command line.  Testing is aborted when an expression does not match (or
Packit 8fb591
does match, if the \fB-i\fP option is used.)
Packit 8fb591
.TP
Packit 8fb591
.BR "\-i\fR,\fP \-\^\-invert-match"
Packit 8fb591
.br
Packit 8fb591
Reverse match condition for the previous pattern.  If the pattern matches,
Packit 8fb591
an error is printed and evaluation is aborted.
Packit 8fb591
.TP
Packit 8fb591
.BR "\fISTRING\fP"
Packit 8fb591
.br
Packit 8fb591
Target text input to match the regular expression(s) against.  The same
Packit 8fb591
text is used for all regular expressions.  Note that only the first
Packit 8fb591
argument is used by \fByangre\fP, if it contains spaces or other shell
Packit 8fb591
metacharacters they must be properly escaped.  Additional arguments are
Packit 8fb591
silently ignored.
Packit 8fb591
.SH FILE INPUT
Packit 8fb591
.TP
Packit 8fb591
.BR "\-f \fIFILE\fP\fR,\fP \-\^\-file=\fIFILE\fP"
Packit 8fb591
Read both patterns and target text from the specified input file.
Packit 8fb591
Packit 8fb591
\fIFILE\fP must consist of one or more YANG regular expressions, each on
Packit 8fb591
their own line, followed by a blank line and one line of target text.  No
Packit 8fb591
preprocessing is done on file input, there are no comment lines and
Packit 8fb591
whitespace is not stripped.  A single space character at the beginning of
Packit 8fb591
a pattern line inverts the match condition for the pattern on that line.
Packit 8fb591
Patterns must still be properly quoted as mandated by the YANG standard.
Packit 8fb591
.SH RETURN VALUES
Packit 8fb591
.TP
Packit 8fb591
0
Packit 8fb591
.I Successful match
Packit 8fb591
.br
Packit 8fb591
The target text matched for all patterns.
Packit 8fb591
.TP
Packit 8fb591
1
Packit 8fb591
.I Pattern mismatch
Packit 8fb591
.br
Packit 8fb591
One or more patterns did not match the target text.  An error message is
Packit 8fb591
printed to stderr describing which pattern was the first not to match.
Packit 8fb591
.TP
Packit 8fb591
255
Packit 8fb591
.I Other error
Packit 8fb591
.br
Packit 8fb591
One or more patterns could not be processed or some other error occurred that
Packit 8fb591
precluded processing.
Packit 8fb591
.SH EXAMPLES
Packit 8fb591
.IP \[bu] 2
Packit 8fb591
Test a single pattern:
Packit 8fb591
    yangre -p 'te.*xt' text_text
Packit 8fb591
.IP \[bu]
Packit 8fb591
Test multiple patterns:
Packit 8fb591
    yangre -p '.*pat1' -p 'pat2.*' -p 'notpat' -i pat2testpat1
Packit 8fb591
.IP \[bu]
Packit 8fb591
Input from a file:
Packit 8fb591
    cat > /tmp/patterns <
Packit 8fb591
    .*pat1
Packit 8fb591
    pat2.*
Packit 8fb591
     notpat
Packit 8fb591
Packit 8fb591
    pat2testpat1
Packit 8fb591
    EOF
Packit 8fb591
    yangre -f /tmp/patterns
Packit 8fb591
Packit 8fb591
.SH SEE ALSO
Packit 8fb591
https://github.com/CESNET/libyang (libyang homepage and Git repository)
Packit 8fb591
.
Packit 8fb591
.SH AUTHORS
Packit 8fb591
Radek Krejci <rkrejci@cesnet.cz>, Michal Vasko <mvasko@cesnet.cz>
Packit 8fb591
.br
Packit 8fb591
This man page was written by David Lamparter <equinox@diac24.net>
Packit 8fb591
.
Packit 8fb591
.SH COPYRIGHT
Packit 8fb591
Copyright \(co 2015-2018 CESNET, a.l.e.