#!/usr/bin/env ruby # -*- encoding: binary -*- # Copyright (C) 2013, Eric Wong # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) require 'dtas/edit_client' include DTAS::EditClient c = client_socket sources = c.req('source ls') || "(unknown)" usage = "Usage: #{DTAS_PROGNAME} SOURCENAME\n" \ "available SOURCENAME values: #{sources}" ARGV.size <= 1 or abort usage name = ARGV[0] || "sox" tmp = tmpyaml buf = c.req(%W(source cat #{name})) abort(buf) if buf =~ /\AERR/ orig = YAML.load(buf) tmp.write(buf << DTAS_DISCLAIMER) cmd = "#{editor} #{tmp.path}" system(cmd) or abort "#{cmd} failed: #$?" tmp.rewind source = YAML.load(tmp.read) cmd = %W(source ed #{name}) update_cmd_env(cmd, orig, source) # nil OK %w(tryorder command).each do |field| cmd << "#{field}=#{source[field]}" end c.req_ok(cmd)