Class: EasyCaddy::Commands::Edit
- Inherits:
-
Object
- Object
- EasyCaddy::Commands::Edit
- Defined in:
- lib/easy_caddy/commands/edit.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name:) ⇒ Edit
constructor
A new instance of Edit.
Constructor Details
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/easy_caddy/commands/edit.rb', line 15 def call site = @registry.find(@name) unless site warn " Site '#{@name}' is not registered." exit 1 end file = site.enabled ? Paths.site_file(@name) : Paths.disabled_file(@name) unless file.exist? warn " Fragment file not found: #{file}" exit 1 end editor = ENV.fetch('EDITOR', 'vi') system("#{editor} #{file}") Caddy.validate!(Paths.caddyfile) Caddy.reload(Paths.caddyfile) if site.enabled puts " Saved and reloaded." end |