Skip to content

Commit

Permalink
* Fixed: [Is it possible to hide non-terminal commands? #31](#31)
Browse files Browse the repository at this point in the history
* Removed "auth" as a local variable in docs, since it is not implemented
  • Loading branch information
olofhagsand committed Nov 24, 2019
1 parent cfd37c4 commit 0d02705
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Cligen Changelog

## 4.3.0 (Expected: December 2019)
Bumped version to match with clixon 4.3

* Fixed: [Is it possible to hide non-terminal commands? #31](https://github.com/olofhagsand/cligen/issues/31)
* Removed "auth" as a local variable in docs, since it is not implemented


## 4.0.1 (18 August 2019)
No new functionality, just a release number bump to synchronize with Clixon

Expand Down
11 changes: 7 additions & 4 deletions cligen_parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,14 @@ cgy_terminal(cliyacc *ya)

for (cl = ya->ya_list; cl; cl = cl->cl_next){
co = cl->cl_obj;

if (ya->ya_callbacks){ /* callbacks */
ccp = &co->co_callbacks;
while (*ccp != NULL)
ccp = &((*ccp)->cc_next);
if (co_callback_copy(ya->ya_callbacks, ccp) < 0)
goto done;
}
/* variables: special case hide, auth */
/* variables: special case "hide" */
if (ya->ya_cvec){
if (cvec_find(ya->ya_cvec, "hide") != NULL)
co->co_hide = 1;
Expand Down Expand Up @@ -701,8 +700,9 @@ cgy_terminal(cliyacc *ya)
static int
ctx_push(cliyacc *ya)
{
struct cgy_list *cl;
struct cgy_stack *cs;
struct cgy_list *cl;
struct cgy_stack *cs;
cg_obj *co;

if (debug)
fprintf(stderr, "%s\n", __FUNCTION__);
Expand All @@ -714,6 +714,9 @@ ctx_push(cliyacc *ya)
cs->cs_next = ya->ya_stack;
ya->ya_stack = cs;
for (cl = ya->ya_list; cl; cl = cl->cl_next){
co = cl->cl_obj;
if (cvec_find(ya->ya_cvec, "hide") != NULL)
co->co_hide = 1;
if (cgy_list_push(cl->cl_obj, &cs->cs_list) < 0)
return -1;
}
Expand Down
Binary file modified cligen_tutorial.pdf
Binary file not shown.
19 changes: 6 additions & 13 deletions cligen_tutorial.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%
% Title
%
\title {CLIgen Manual\\ {\small CLIgen version 3.9}}
\title {CLIgen Manual\\ {\small CLIgen version 4.3}}

\author{Olof Hagsand}
%
Expand Down Expand Up @@ -86,8 +86,7 @@ \section{Introduction}
are a part of the API described in Section~\ref{sec:api}.
\item
\emph{Assignments} are used to set properties of the CLI and its
commands, such as prompts, modes authorization, visibility,
etc. Assignments are either global or per-command.
commands, such as prompts, visibility, etc. Assignments are either global or per-command.
\item
\emph{Help text} provides help text for individual commands.
\item
Expand Down Expand Up @@ -274,27 +273,21 @@ \subsection{Assignments}
variables. Global variables are valid for the whole syntax, while
local variables only apply to a single command.

In the current release, there are two pre-defined local variables:
In the current release, there is one pre-defined local variable:
\begin{itemize}
\item
{\tt hide} specifies that a command is not visible when listing or
completing commands with '?' and 'TAB'. Still, the command is
selectable and may be selected if you type it. This can be useful if there are
commands that should be known only by expert users.
\item
{\tt auth}. defines authorization level the user should have to be
able to use the command.
\end{itemize}

In the following example, {\tt aa bb ca} is not visible,
whereas {\tt aa bb cb} and {\tt aa bb cb dd} are only shown if the
user has {\tt show commands} priviligies.
In the following example, {\tt aa bb ca} is not visible:
\begin{verbatim}
aa bb{
ca,hide;
cb,auth="show";{
dd,auth="show";
ee;
cb;{
dd;
}
}
\end{verbatim}
Expand Down

0 comments on commit 0d02705

Please sign in to comment.