#!/usr/bin/env ruby # frozen_string_literal: true require 'archival' VALID_COMMANDS = %w[ build run ].freeze command = ARGV[0] unless !command || VALID_COMMANDS.include?(command) raise StandardError, "Invalid command #{command}" end build_dir = Dir.pwd case command when 'build' builder = Archival::Builder.new('root' => build_dir) builder.write_all when 'run' Archival.listen(build_dir) begin sleep rescue Interrupt # Don't print a stack when a user interrupts, as this is the right way to # stop the development server. puts '' end else # print help puts 'archival [command]' puts '' puts 'Commands:' puts ' build Builds the current directory as an archival website.' puts ' run Runs the current directory in development mode, ' + 'recompiling when files change.' end