From 331585f45b38cd87657bff531b5e25d68a242541 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 12 Apr 2024 12:35:08 +0200 Subject: [PATCH] CLI: Added multiple inline commands separated by ; --- CHANGELOG.md | 1 + apps/cli/cli_main.c | 48 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73a90885..def33a54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Expected: June 2024 * CLI configurable format: [Default format should be configurable](https://github.com/clicon/clixon-controller/issues/87) +* CLI support for multiple inline commands separated by semi-colon * New `clixon-config@2024-04-01.yang` revision * Added options: - `CLICON_NETCONF_DUPLICATE_ALLOW` - Disable duplicate check in NETCONF messages diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 36af6ffe..235fefe6 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -469,6 +469,44 @@ options_split(clixon_handle h, return retval; } +/*! Evaluate remaining commands on the command-line + * + * @param[in] h Clixon handle + * @param[in] restarg Remaining commands, separated by \; + * @retval 0 OK + * @retval -1 Error + */ +static int +rest_commands(clixon_handle h, + char *restarg) +{ + int retval = -1; + char *mode = cli_syntax_mode(h); + cligen_result result; /* match result */ + int evalresult = 0; /* if result == 1, callback result */ + char **vec = NULL; + char *v; + int nvec; + int i; + + if ((vec = clicon_strsep(restarg, ";", &nvec)) == NULL) + goto done; + for (i=0; i