Class: DnsMadeEasy::CLI::Commands::Zone::Format

Inherits:
Base
  • Object
show all
Defined in:
lib/dnsmadeeasy/cli/commands/zone.rb

Overview

Formats a standard DNS zone file into canonical output.

Constant Summary

Constants inherited from Base

Base::DEFAULT_CREDENTIAL_PATHS, Base::SUPPORTED_FORMATS

Constants included from MessageHelpers

MessageHelpers::BOX_OPTIONS, MessageHelpers::KEY_WIDTH

Instance Method Summary collapse

Methods included from MessageHelpers

error, included, info, kv, print_box, success, warn

Instance Method Details

#call(file:) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 88

def call(file:, **)
  result = DnsMadeEasy::Zone::Parser.new(::File.read(file)).call

  if result.success?
    puts DnsMadeEasy::Zone::Serializer.new(result.value!)
    success("Zone file formatted.\n#{kv('Records', result.value!.records.length)}")
  else
    error("Zone file is invalid.\n#{result.failure.join("\n")}")
    raise ReportedError, 'zone file is invalid'
  end
end