lncli: add fish-completion

This is a new, hidden command that generates completions for Fish shell.
This can be piped into `source` or saved in a file to activate (almost)
perfect tab completion.
This commit is contained in:
Torkel Rogstad
2020-04-26 17:13:06 +02:00
parent c64e9c5286
commit 55617f153f
3 changed files with 44 additions and 21 deletions

View File

@@ -2127,6 +2127,22 @@ func updateChannelPolicy(ctx *cli.Context) error {
return nil return nil
} }
var fishCompletionCommand = cli.Command{
Name: "fish-completion",
Hidden: true,
Action: func(c *cli.Context) error {
completion, err := c.App.ToFishCompletion()
if err != nil {
return err
}
// We don't want to suggest files, so we add this
// first line to the completions.
_, err = fmt.Printf("complete -c %q -f \n%s", c.App.Name, completion)
return err
},
}
var exportChanBackupCommand = cli.Command{ var exportChanBackupCommand = cli.Command{
Name: "exportchanbackup", Name: "exportchanbackup",
Category: "Channels", Category: "Channels",

View File

@@ -390,6 +390,7 @@ func main() {
deletePaymentsCommand, deletePaymentsCommand,
sendCustomCommand, sendCustomCommand,
subscribeCustomCommand, subscribeCustomCommand,
fishCompletionCommand,
} }
// Add any extra commands determined by build flags. // Add any extra commands determined by build flags.

View File

@@ -1,25 +1,26 @@
# Table of Contents # Table of Contents
* [Installation](#installation) - [Table of Contents](#table-of-contents)
* [Installing a binary release](#installing-a-binary-release) - [Installation](#installation)
* [Building a tagged version with Docker](#building-a-tagged-version-with-docker) - [Installing a binary release](#installing-a-binary-release)
* [Building a development version from source](#building-a-development-version-from-source) - [Building a tagged version with Docker](#building-a-tagged-version-with-docker)
* [Preliminaries](#preliminaries-for-installing-from-source) - [Building a development version from source](#building-a-development-version-from-source)
* [Installing lnd](#installing-lnd-from-source) - [Preliminaries for installing from source](#preliminaries-for-installing-from-source)
* [Available Backend Operating Modes](#available-backend-operating-modes) - [Installing lnd from source](#installing-lnd-from-source)
* [btcd Options](#btcd-options) - [Available Backend Operating Modes](#available-backend-operating-modes)
* [Neutrino Options](#neutrino-options) - [btcd Options](#btcd-options)
* [Bitcoind Options](#bitcoind-options) - [Neutrino Options](#neutrino-options)
* [Using btcd](#using-btcd) - [Bitcoind Options](#bitcoind-options)
* [Installing btcd](#installing-btcd) - [Using btcd](#using-btcd)
* [Starting btcd](#starting-btcd) - [Installing btcd](#installing-btcd)
* [Running lnd using the btcd backend](#running-lnd-using-the-btcd-backend) - [Starting btcd](#starting-btcd)
* [Using Neutrino](#using-neutrino) - [Running lnd using the btcd backend](#running-lnd-using-the-btcd-backend)
* [Using bitcoind or litecoind](#using-bitcoind-or-litecoind) - [Using Neutrino](#using-neutrino)
* [Creating a Wallet](#creating-a-wallet) - [Using bitcoind or litecoind](#using-bitcoind-or-litecoind)
* [Macaroons](#macaroons) - [Creating a wallet](#creating-a-wallet)
* [Network Reachability](#network-reachability) - [Macaroons](#macaroons)
* [Simnet vs. Testnet Development](#simnet-vs-testnet-development) - [Network Reachability](#network-reachability)
* [Creating an lnd.conf (Optional)](#creating-an-lndconf-optional) - [Simnet vs. Testnet Development](#simnet-vs-testnet-development)
- [Creating an lnd.conf (Optional)](#creating-an-lndconf-optional)
# Installation # Installation
@@ -241,6 +242,11 @@ To check that `lnd` was installed properly run the following command:
This command requires `bitcoind` (almost any version should do) to be available This command requires `bitcoind` (almost any version should do) to be available
in the system's `$PATH` variable. Otherwise some of the tests will fail. in the system's `$PATH` variable. Otherwise some of the tests will fail.
**Command-line completion for `lncli`**
_Bash_: See `contrib/lncli.bash-completion`
_Fish_: Run: `lncli fish-completion > $HOME/.config/fish/completions/lncli.fish`
# Available Backend Operating Modes # Available Backend Operating Modes
In order to run, `lnd` requires, that the user specify a chain backend. At the In order to run, `lnd` requires, that the user specify a chain backend. At the