From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Giuseppe Longo <giuseppelng@gmail.com>
Cc: "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>
Subject: Re: [RFC nftables PATCH] nft: add bash completion script
Date: Tue, 16 Feb 2016 17:26:34 +0100 [thread overview]
Message-ID: <20160216162634.GB3504@salvia> (raw)
In-Reply-To: <CAFpD06Q_eVk6xPeQH6GVrsHVNQCdXKvuCh-5T3Wi_sHK3tmQrQ@mail.gmail.com>
On Tue, Feb 16, 2016 at 02:00:17PM +0100, Giuseppe Longo wrote:
> Hi Pablo,
>
> 2016-02-15 20:56 GMT+01:00 Pablo Neira Ayuso <pablo@netfilter.org>:
> > Hi Giuseppe,
> >
> > On Fri, Feb 05, 2016 at 05:53:02PM +0100, Giuseppe Longo wrote:
> >> The following patch adds a bash completion script
> >> which permits to complete nft commands.
> >>
> >> To install it:
> >> - cp files/nft-completion /etc/bash_completion.d/
> >> - . /etc/bash_completion.d/nft-completion
> >>
> >> The following commands are supported:
> >> - nft add table <family> <name>
> >> - nft list table <family> <name>
> >> - nft list tables
> >> - nft list sets
> >> - nft list chains
> >> - nft list ruleset
> >> - nft list set <table> <name>
> >> - nft add set <table> <name>
> >> - nft add element <table> <set>
> >> - nft add map <table>
> >> - nft flush table <family> <table>
> >>
> >> Most probably this won't work with sudo, since there
> >> are some nft commands into the script.
> >>
> >> A second patch to add completion in interactive mode
> >> will come.
> >>
> >> This is only a draft,
> >> any feedback is appreciated.
> >
> > Could you explore adding code to inquire the parser on the next
> > possible tokens ahead? That would greatly simplify the shell script
> > for bash autocompletion. We should be able to reuse this from
> > libreadline too.
> >
> > I know what I'm asking is a bit more difficult, but it would help us
> > reduce the amount of code duplication and will reduce the maintainance
> > burden.
> >
> > Let us know, thanks!
>
> Sure, I've looked quickly at bison doc and thought the following idea:
> We can add a new nft command like "nft complete" to inquire the parser,
> which will print all the possible word since we have a parse tree.
Sounds reasonable. Let me see if I can come up with a better command
name, but this naming detail should not stop you at this stage.
> in that way, the bash script will be able to complete the command.
>
> Also, do you confirm that we will skip objects like tables name, chain
> name, and so on?
Yes, let's focus on keyword autocompletion by now.
Thanks.
prev parent reply other threads:[~2016-02-16 16:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 16:53 [RFC nftables PATCH] nft: add bash completion script Giuseppe Longo
2016-02-06 7:56 ` AllKind
2016-02-06 20:13 ` AllKind
2016-02-15 19:56 ` Pablo Neira Ayuso
2016-02-16 13:00 ` Giuseppe Longo
2016-02-16 16:26 ` Pablo Neira Ayuso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160216162634.GB3504@salvia \
--to=pablo@netfilter.org \
--cc=giuseppelng@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).