# class Chef::Knife::NodeRunListAdd

### Public Instance Methods

run() click to toggle source

    # File lib/chef/knife/node_run_list_add.rb, line 42
    def run
      node = Chef::Node.load(@name_args[0])
      if @name_args.size > 2
        # Check for nested lists and create a single plain one
        entries = @name_args[1..-1].map do |entry|
          entry.split(',').map { |e| e.strip }
        end.flatten
      else
        # Convert to array and remove the extra spaces
        entries = @name_args[1].split(',').map { |e| e.strip }
      end

      if config[:after] && config[:before]
        ui.fatal("You cannot specify both --before and --after!")
        exit 1
      end

      if config[:after]
        add_to_run_list_after(node, entries, config[:after])
      elsif config[:before]
        add_to_run_list_before(node, entries, config[:before])
      else
        add_to_run_list_after(node, entries)
      end

      node.save

      config[:run_list] = true

      output(format_for_display(node))
    end