2019-03-11 16:56:48 +00:00
|
|
|
package cmd
|
2015-06-08 00:36:07 +00:00
|
|
|
|
|
|
|
import (
|
2016-03-18 00:32:24 +00:00
|
|
|
"fmt"
|
2019-07-10 17:34:10 +00:00
|
|
|
"io"
|
2019-03-08 18:47:06 +00:00
|
|
|
"strings"
|
2016-03-18 00:32:24 +00:00
|
|
|
"text/tabwriter"
|
2015-06-08 00:36:07 +00:00
|
|
|
|
2022-02-13 11:28:51 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2015-06-08 00:36:07 +00:00
|
|
|
)
|
|
|
|
|
2024-09-20 17:47:50 +00:00
|
|
|
const flgCode = "code"
|
|
|
|
|
2022-02-13 11:28:51 +00:00
|
|
|
func createDNSHelp() *cli.Command {
|
|
|
|
return &cli.Command{
|
2018-12-06 21:50:17 +00:00
|
|
|
Name: "dnshelp",
|
2019-03-08 18:47:06 +00:00
|
|
|
Usage: "Shows additional help for the '--dns' global option",
|
2018-12-06 21:50:17 +00:00
|
|
|
Action: dnsHelp,
|
2019-03-08 18:47:06 +00:00
|
|
|
Flags: []cli.Flag{
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2024-09-20 17:47:50 +00:00
|
|
|
Name: flgCode,
|
2022-02-13 11:28:51 +00:00
|
|
|
Aliases: []string{"c"},
|
|
|
|
Usage: fmt.Sprintf("DNS code: %s", allDNSCodes()),
|
2019-03-08 18:47:06 +00:00
|
|
|
},
|
|
|
|
},
|
2016-05-14 15:11:26 +00:00
|
|
|
}
|
2015-06-08 00:36:07 +00:00
|
|
|
}
|
2016-03-18 00:32:24 +00:00
|
|
|
|
2019-03-08 18:47:06 +00:00
|
|
|
func dnsHelp(ctx *cli.Context) error {
|
2024-09-20 17:47:50 +00:00
|
|
|
code := ctx.String(flgCode)
|
2019-03-08 18:47:06 +00:00
|
|
|
if code == "" {
|
2023-01-08 13:53:15 +00:00
|
|
|
w := tabwriter.NewWriter(ctx.App.Writer, 0, 0, 2, ' ', 0)
|
2019-07-10 17:34:10 +00:00
|
|
|
ew := &errWriter{w: w}
|
2019-03-08 18:47:06 +00:00
|
|
|
|
2019-07-10 17:34:10 +00:00
|
|
|
ew.writeln(`Credentials for DNS providers must be passed through environment variables.`)
|
|
|
|
ew.writeln()
|
2023-01-08 13:53:15 +00:00
|
|
|
ew.writeln(`To display the documentation for a specific DNS provider, run:`)
|
2019-07-10 17:34:10 +00:00
|
|
|
ew.writeln()
|
|
|
|
ew.writeln("\t$ lego dnshelp -c code")
|
|
|
|
ew.writeln()
|
2023-01-08 13:53:15 +00:00
|
|
|
ew.writeln("Supported DNS providers:")
|
2019-07-10 17:34:10 +00:00
|
|
|
ew.writef("\t%s\n", allDNSCodes())
|
|
|
|
ew.writeln()
|
|
|
|
ew.writeln("More information: https://go-acme.github.io/lego/dns")
|
|
|
|
|
|
|
|
if ew.err != nil {
|
|
|
|
return ew.err
|
|
|
|
}
|
2019-03-08 18:47:06 +00:00
|
|
|
|
|
|
|
return w.Flush()
|
|
|
|
}
|
2016-03-18 00:32:24 +00:00
|
|
|
|
2023-01-08 13:53:15 +00:00
|
|
|
return displayDNSHelp(ctx.App.Writer, strings.ToLower(code))
|
2019-07-10 17:34:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type errWriter struct {
|
|
|
|
w io.Writer
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ew *errWriter) writeln(a ...interface{}) {
|
|
|
|
if ew.err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
_, ew.err = fmt.Fprintln(ew.w, a...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ew *errWriter) writef(format string, a ...interface{}) {
|
|
|
|
if ew.err != nil {
|
|
|
|
return
|
|
|
|
}
|
2016-05-12 17:52:59 +00:00
|
|
|
|
2019-07-10 17:34:10 +00:00
|
|
|
_, ew.err = fmt.Fprintf(ew.w, format, a...)
|
2016-03-18 00:32:24 +00:00
|
|
|
}
|