Method: NHKore::App#refresh_cmd

Defined in:
lib/nhkore/app.rb

#refresh_cmd(opts, args, cmd) ⇒ Object



480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/nhkore/app.rb', line 480

def refresh_cmd(opts,args,cmd)
  new_opts = {}

  # Change symbols with dashes to underscores,
  #   so don't have to type @cmd_opts[:'dry-run'] all the time.
  opts.each do |key,value|
    # %s(max-retry) => :max_retry
    key = key.to_s.gsub('-','_').to_sym

    new_opts[key] = value
  end

  # For now don't set the default proc, as the original code
  #   did not have this in mind.
  # Specifically, SiftCmd.build_sift_filename() is affected by
  #   this due to relying on @cmd_opts[:ext] to be nil.
  #   It's easy to change this one instance, but I'm not sure
  #   at the moment where else might be affected
  #
  # # Cri has a default proc for default values
  # #   that doesn't store the keys.
  # new_opts.default_proc = proc do |hash,key|
  #   # :max_retry => %s(max-retry)
  #   key = key.to_s.gsub('_','-').to_sym
  #
  #   opts.default_proc.call(hash,key)
  # end

  @cmd = cmd
  @cmd_args = args
  @cmd_opts = new_opts

  return self
end