diff --git a/commands/previewPush.go b/commands/previewPush.go index 1de4a568d..1471f99e1 100644 --- a/commands/previewPush.go +++ b/commands/previewPush.go @@ -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 diff --git a/docs/_functions/global/D_EXTEND.md b/docs/_functions/global/D_EXTEND.md index 7c09b0b39..58f10c536 100644 --- a/docs/_functions/global/D_EXTEND.md +++ b/docs/_functions/global/D_EXTEND.md @@ -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 diff --git a/docs/_functions/global/getConfiguredDomains.md b/docs/_functions/global/getConfiguredDomains.md index c766581db..1cc56110f 100644 --- a/docs/_functions/global/getConfiguredDomains.md +++ b/docs/_functions/global/getConfiguredDomains.md @@ -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 diff --git a/docs/_providers/route53.md b/docs/_providers/route53.md index a703e83e9..c098dbda0 100644 --- a/docs/_providers/route53.md +++ b/docs/_providers/route53.md @@ -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 diff --git a/docs/getting-started.md b/docs/getting-started.md index 4ba4adac6..90d283828 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -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 diff --git a/pkg/nameservers/nameservers.go b/pkg/nameservers/nameservers.go index cfa8a7baa..f3b524e86 100644 --- a/pkg/nameservers/nameservers.go +++ b/pkg/nameservers/nameservers.go @@ -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 diff --git a/pkg/printer/printer.go b/pkg/printer/printer.go index a03cc6274..798929ead 100644 --- a/pkg/printer/printer.go +++ b/pkg/printer/printer.go @@ -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) } }