Sha256: 689194d61cae9e761d62e6accad30032f180a998821a7963940dfece11203799

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require "thor"

module Zonesync
  class CLI < Thor
    default_command :sync
    desc "sync --source=Zonefile --destination=zonesync", "syncs the contents of the Zonefile to the DNS server configured in Rails.application.credentials.zonesync"
    option :source, default: "Zonefile", desc: "path to the zonefile"
    option :destination, default: "zonesync", desc: "key to the DNS server configuration in Rails.application.credentials"
    method_option :dry_run, type: :boolean, default: false, aliases: :n, desc: "log operations to STDOUT but don't perform the sync"
    def sync
      kwargs = options.to_hash.transform_keys(&:to_sym)
      Zonesync.call(**kwargs)
    rescue ConflictError, MissingManifestError, ChecksumMismatchError => e
      puts e.message
      exit 1
    end

    desc "generate --source=zonesync --destination=Zonefile", "generates a Zonefile from the DNS server configured in Rails.application.credentials.zonesync"
    option :source, default: "zonesync", desc: "key to the DNS server configuration in Rails.application.credentials"
    option :destination, default: "Zonefile", desc: "path to the zonefile"
    def generate
      kwargs = options.to_hash.transform_keys(&:to_sym)
      Zonesync.generate(**kwargs)
    end

    def self.exit_on_failure? = true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zonesync-0.9.0 lib/zonesync/cli.rb