1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
* fix linting
* rename AuditRecordsor to RecordAuditor
* gandi_v5 to gandiv5
This commit is contained in:
Tom Limoncelli
2021-03-08 20:14:30 -05:00
committed by GitHub
parent c883c1ac68
commit e69e6f27e4
36 changed files with 49 additions and 47 deletions

View File

@@ -21,6 +21,7 @@ var _ = cmd(catUtils, func() *cli.Command {
}
}())
// FmtArgs stores arguments related to the fmt subcommand.
type FmtArgs struct {
InputFile string
OutputFile string
@@ -44,6 +45,7 @@ func (args *FmtArgs) flags() []cli.Flag {
return flags
}
// FmtFile reads and formats a file.
func FmtFile(args FmtArgs) error {
fileBytes, readErr := ioutil.ReadFile(args.InputFile)
if readErr != nil {
@@ -62,14 +64,13 @@ func FmtFile(args FmtArgs) error {
beautified = beautified + "\n"
}
if args.OutputFile != "" {
if args.OutputFile == "" {
fmt.Print(beautified)
} else {
if err := ioutil.WriteFile(args.OutputFile, []byte(beautified), 0744); err != nil {
return err
} else {
fmt.Fprintf(os.Stderr, "File %s successfully written\n", args.OutputFile)
}
} else {
fmt.Print(beautified)
fmt.Fprintf(os.Stderr, "File %s successfully written\n", args.OutputFile)
}
return nil
}