Skip to content

RFC Add Linenoise support to the CLI.

Jeremy Sowden netfilter-devel 1 version Applied

Status from this message: Applied this patch to reduce your next batch, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 6 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4configure: remove unused AC_SUBST macros.configure.ac+0 -21 reply
2/4cli: remove unused declaration.include/cli.h+0 -11 reply
3/4cli: add upstream linenoise source.linenoise/LICENSE linenoise/Makefile linenoise/README.markdown +3 more+1609 -00 replies
4/4cli: add linenoise CLI implementation.Makefile.am configure.ac include/cli.h +5 more+101 -152 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC nftables 0/4] Add Linenoise support to the CLI.

Sebastian Priebe [0] requested Linenoise support for the CLI as an alternative to Readline, so I thought I'd have a go at providing it. Linenoise is a minimal, zero-config, BSD licensed, Readline replacement used in Redis, MongoDB, and Android [1].

0 - https://lore.kernel.org/netfilter-devel/[email protected]/
1 - https://github.com/antirez/linenoise/

The upstream repo doesn't contain the infrastructure for building or installing libraries. I've taken a look at how Redis and MongoDB handle this, and they both include the upstream sources in their trees (MongoDB actually uses a C++ fork, Linenoise NG [2]), so I've done the same.

2 - https://github.com/arangodb/linenoise-ng

Initially, I added the Linenoise header to include/ and the source to src/, but the compiler warning flags used by upstream differ from those used by nftables, which meant that the compiler emitted warnings when compiling the Linenoise source and I had to edit it to fix them. Since they were benign and editing the source would make it more complicated to update from upstream in the future, I have, instead, chosen to put everything in a separate linenoise/ directory with its own Makefile.am and the same warning flags as upstream.

By default, the CLI continues to be build using Readline, but passing with-cli=linenoise instead causes Linenoise to be used instead.

The first two patches do a bit of tidying; the third patch adds the Linenoise sources; the last adds Linenoise support to the CLI.

Jeremy Sowden (4):
configure: remove unused AC_SUBST macros.
cli: remove unused declaration.
cli: add upstream linenoise source.
cli: add linenoise CLI implementation.

 Makefile.am                 |    7 +-
 configure.ac                |   20 +-
 include/cli.h               |    3 +-
 linenoise/.gitignore        |    6 +
 linenoise/LICENSE           |   25 +
 linenoise/Makefile.am       |   13 +
 linenoise/Makefile.upstream |    7 +
 linenoise/README.markdown   |  229 +++++++
 linenoise/example.c         |   74 +++
 linenoise/linenoise.c       | 1201 +++++++++++++++++++++++++++++++++++
 linenoise/linenoise.h       |   73 +++
 src/Makefile.am             |    6 +
 src/cli.c                   |   64 +-
 13 files changed, 1710 insertions(+), 18 deletions(-)
 create mode 100644 linenoise/.gitignore
 create mode 100644 linenoise/LICENSE
 create mode 100644 linenoise/Makefile.am
 create mode 100644 linenoise/Makefile.upstream
 create mode 100644 linenoise/README.markdown
 create mode 100644 linenoise/example.c
 create mode 100644 linenoise/linenoise.c
 create mode 100644 linenoise/linenoise.h
Signature · 1 line
2.23.0