mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-15 09:34:24 +08:00
Add --verbose flag, default to less verbose output (#1721)
This commit is contained in:
parent
d907cdd2c2
commit
8bb63be8f5
7 changed files with 35 additions and 6 deletions
|
@ -37,6 +37,7 @@ type PreviewArgs struct {
|
|||
Notify bool
|
||||
WarnChanges bool
|
||||
NoPopulate bool
|
||||
Full bool
|
||||
}
|
||||
|
||||
func (args *PreviewArgs) flags() []cli.Flag {
|
||||
|
@ -58,6 +59,11 @@ func (args *PreviewArgs) flags() []cli.Flag {
|
|||
Destination: &args.NoPopulate,
|
||||
Usage: `Use this flag to not auto-create non-existing zones at the provider`,
|
||||
})
|
||||
flags = append(flags, &cli.BoolFlag{
|
||||
Name: "full",
|
||||
Destination: &args.Full,
|
||||
Usage: `Add headings, providers names, notifications of no changes, etc`,
|
||||
})
|
||||
return flags
|
||||
}
|
||||
|
||||
|
@ -102,6 +108,10 @@ func Push(args PushArgs) error {
|
|||
// run is the main routine common to preview/push
|
||||
func run(args PreviewArgs, push bool, interactive bool, out printer.CLI) error {
|
||||
// TODO: make truly CLI independent. Perhaps return results on a channel as they occur
|
||||
|
||||
// This is a hack until we have the new printer replacement.
|
||||
printer.SkinnyReport = !args.Full
|
||||
|
||||
cfg, err := GetDNSConfig(args.GetDNSConfigArgs)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -57,7 +57,7 @@ D_EXTEND("sub.domain.tld",
|
|||
);
|
||||
```
|
||||
|
||||
This will end up in the following modifications:
|
||||
This will end up in the following modifications: (This output assumes the `--verbose` flag)
|
||||
|
||||
```text
|
||||
******************** Domain: domain.tld
|
||||
|
|
|
@ -21,7 +21,8 @@ for(i = 0; i < domains.length; i++) {
|
|||
}
|
||||
```
|
||||
|
||||
This will end up in following modifications:
|
||||
This will end up in following modifications: (All output assumes the `--verbose` flag)
|
||||
|
||||
|
||||
```text
|
||||
******************** Domain: domain1.tld
|
||||
|
|
|
@ -140,7 +140,8 @@ This code may not function properly if a domain has R53 as a Registrar
|
|||
but not as a DnsProvider. The situation is described in
|
||||
[PR#155](https://github.com/StackExchange/dnscontrol/pull/155).
|
||||
|
||||
In this situation you will see a message like:
|
||||
In this situation you will see a message like: (This output assumes the `--verbose` flag)
|
||||
|
||||
|
||||
```text
|
||||
----- Registrar: r53_main
|
||||
|
|
|
@ -172,6 +172,8 @@ what changes need to be made and never makes any actual changes.
|
|||
It will use APIs if needed to find out what DNS entries currently
|
||||
exist.
|
||||
|
||||
(All output assumes the `--verbose` flag)
|
||||
|
||||
It should look something like this:
|
||||
|
||||
```text
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
)
|
||||
|
||||
// DetermineNameservers will find all nameservers we should use for a domain. It follows the following rules:
|
||||
|
@ -25,7 +26,9 @@ func DetermineNameserversForProviders(dc *models.DomainConfig, providers []*mode
|
|||
if n == 0 {
|
||||
continue
|
||||
}
|
||||
fmt.Printf("----- Getting nameservers from: %s\n", dnsProvider.Name)
|
||||
if !printer.SkinnyReport {
|
||||
fmt.Printf("----- Getting nameservers from: %s\n", dnsProvider.Name)
|
||||
}
|
||||
nss, err := dnsProvider.Driver.GetNameservers(dc.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -66,6 +66,11 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// SkinnyReport is true to to disable certain print statements.
|
||||
// This is a hack until we have the new printer replacement. The long
|
||||
// variable name is easy to grep for when we make the conversion.
|
||||
var SkinnyReport = true
|
||||
|
||||
// ConsolePrinter is a handle for the console printer.
|
||||
type ConsolePrinter struct {
|
||||
Reader *bufio.Reader
|
||||
|
@ -117,7 +122,9 @@ func (c ConsolePrinter) StartDNSProvider(provider string, skip bool) {
|
|||
if skip {
|
||||
lbl = " (skipping)\n"
|
||||
}
|
||||
fmt.Fprintf(c.Writer, "----- DNS Provider: %s...%s\n", provider, lbl)
|
||||
if !SkinnyReport {
|
||||
fmt.Fprintf(c.Writer, "----- DNS Provider: %s...%s\n", provider, lbl)
|
||||
}
|
||||
}
|
||||
|
||||
// StartRegistrar is called at the start of each new registrar.
|
||||
|
@ -126,7 +133,9 @@ func (c ConsolePrinter) StartRegistrar(provider string, skip bool) {
|
|||
if skip {
|
||||
lbl = " (skipping)\n"
|
||||
}
|
||||
fmt.Fprintf(c.Writer, "----- Registrar: %s...%s\n", provider, lbl)
|
||||
if !SkinnyReport {
|
||||
fmt.Fprintf(c.Writer, "----- Registrar: %s...%s\n", provider, lbl)
|
||||
}
|
||||
}
|
||||
|
||||
// EndProvider is called at the end of each provider.
|
||||
|
@ -139,6 +148,9 @@ func (c ConsolePrinter) EndProvider(numCorrections int, err error) {
|
|||
if numCorrections == 1 {
|
||||
plural = ""
|
||||
}
|
||||
if (SkinnyReport) && (numCorrections == 0) {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(c.Writer, "%d correction%s\n", numCorrections, plural)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue