Class: ClusterFuck::Commands::Edit

Inherits:
Object
  • Object
show all
Includes:
AmicusEnvArgumentParser, Commander::UI
Defined in:
lib/cluster-fuck/commands/edit.rb

Instance Method Summary collapse

Methods included from AmicusEnvArgumentParser

included, #set_amicus_env_and_key_from_args

Instance Method Details

#readerObject



23
24
25
# File 'lib/cluster-fuck/commands/edit.rb', line 23

def reader
  @reader ||= ClusterFuck::Reader.new(key, amicus_env: amicus_env)
end

#run_command(args, options = Hashie::Mash.new) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
# File 'lib/cluster-fuck/commands/edit.rb', line 9

def run_command(args, options = Hashie::Mash.new)
  set_amicus_env_and_key_from_args(args)

  @options = options
  raise ArgumentError, "File #{key} is overridden locally! use --force to force" if reader.has_local_override? and !options.force

  new_yaml = ask_editor(YAML.dump(reader.read(remote_only: true).to_hash))
  writer.set(Configuration.from_yaml(new_yaml), reader.version_count)
end

#writerObject



19
20
21
# File 'lib/cluster-fuck/commands/edit.rb', line 19

def writer
  @writer ||= ClusterFuck::Writer.new(key, amicus_env: reader.amicus_env)
end