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

Instance Method Summary collapse

Instance Method Details

#call(file:) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 54

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

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