-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linenoise update #2307
Open
lePici
wants to merge
5
commits into
CESNET:devel
Choose a base branch
from
lePici:linenoise
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
linenoise update #2307
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e756c19
yanglint BUGFIX ignore interactive tests
lePici 36415c8
yanglint UPDATE of linenoise
lePici 9b79197
yanglint FEATURE added utf-8 support
lePici dbcc959
yanglint FEATURE enable multiline for linenoise
lePici cbe9ec9
yanglint REFACTOR of completion callback
lePici File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/** | ||
* @file cli_verb.c | ||
* @author Adam Piecek <[email protected]> | ||
* @brief 'cli' command of the libyang's yanglint tool. | ||
* | ||
* Copyright (c) 2024-2024 CESNET, z.s.p.o. | ||
* | ||
* This source code is licensed under BSD 3-Clause License (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
#include "cmd.h" | ||
|
||
#include <getopt.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <strings.h> | ||
|
||
#include "libyang.h" | ||
#include "linenoise/linenoise.h" | ||
|
||
#include "common.h" | ||
#include "yl_opt.h" | ||
|
||
#define LY_CLI_SINGLELINE 0x1 | ||
|
||
uint8_t cli_flags; | ||
|
||
void | ||
cmd_cli_help(void) | ||
{ | ||
printf("Usage: cli [-s]\n" | ||
" Settings for the command line interface.\n\n" | ||
" -s, --toggle-singleline\n" | ||
" The singleline settings toggles how the cli handles the overflow of typed text\n" | ||
" across the screen. By default, it puts overflow text on a new line. But this\n" | ||
" setting will make the text will scroll towards right to make room while\n" | ||
" sending much less ANSI escape codes.\n"); | ||
} | ||
|
||
int | ||
cmd_cli_opt(struct yl_opt *yo, const char *cmdline, char ***posv, int *posc) | ||
{ | ||
int rc = 0, argc = 0; | ||
int opt, opt_index; | ||
struct option options[] = { | ||
{"toggle-singleline", no_argument, NULL, 's'}, | ||
{"help", no_argument, NULL, 'h'}, | ||
{NULL, 0, NULL, 0} | ||
}; | ||
|
||
if ((rc = parse_cmdline(cmdline, &argc, &yo->argv))) { | ||
return rc; | ||
} | ||
|
||
while ((opt = getopt_long(argc, yo->argv, interactive_cmd[CMD_CLI].optstring, options, &opt_index)) != -1) { | ||
switch (opt) { | ||
case 's': | ||
yo->cli_flags |= LY_CLI_SINGLELINE; | ||
break; | ||
case 'h': | ||
cmd_cli_help(); | ||
return 1; | ||
default: | ||
YLMSG_E("Unknown option."); | ||
return 1; | ||
} | ||
} | ||
|
||
*posv = &yo->argv[optind]; | ||
*posc = argc - optind; | ||
|
||
return 0; | ||
} | ||
|
||
int | ||
cmd_cli_dep(struct yl_opt *yo, int posc) | ||
{ | ||
(void) yo; | ||
|
||
if (posc != 0) { | ||
YLMSG_E("Only options are expected."); | ||
cmd_cli_help(); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int | ||
cmd_cli_exec(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv) | ||
{ | ||
(void) ctx, (void) posv; | ||
|
||
if (yo->cli_flags & LY_CLI_SINGLELINE) { | ||
if (cli_flags & LY_CLI_SINGLELINE) { | ||
cli_flags &= ~LY_CLI_SINGLELINE; | ||
linenoiseSetMultiLine(1); | ||
} else { | ||
cli_flags |= LY_CLI_SINGLELINE; | ||
linenoiseSetMultiLine(0); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Unbounded write Critical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a false-positive to me.