<commit_before>require 'easy_type/command_entry'
require 'easy_type/blank_slate'

module EasyType
	#
	# The command builder is a class that helps building an OS command sequence. You can specify 
	# a base command on creation. With the << you can add parameters and options in the order you would 
	# like. Sometimes you need to execute commands before and/or after the base command. The ScriptBuilder
	# supports this by using the `before` and `after` methods
	#
	class ScriptBuilder


		attr_reader :acceptable_commands, :binding

		def initialize(options = {}, &block)
			@entries ||= []
			@acceptable_commands = Array(options.fetch(:acceptable_commands) {[]})
			@binding = options[:binding]
			@context = BlankSlate.new
			if @binding
				CommandEntry.set_binding(@binding)
				copy_resource_info
			end
			@acceptable_commands.each do | command|
				@context.eigenclass.send(:define_method,command) do |*args|
					@entries[type] << CommandEntry.new(command, args)
				end
			end
			@context.type = :main
			@context.instance_eval(&block) if block
		end

		def entries(type = :main)
			@context.entries[type]
		end

		def default_command
			@acceptable_commands.first || ''
		end

		def last_command(type = :main)
			entries(type).last
		end

		def add(*args, &block)
			if block
				add_to_queue(:main, &block)
				nil
			else
				entries(:main) << CommandEntry.new(default_command, args) unless args == [nil] #special case
			end
		end

		def <<(line)
			raise ArgumentError, 'no command specified' unless last_command
			last_command.arguments << line if line
		end

		#
		# For backward compatibility
		#
		def line
			raise ArgumentError, 'no command specified' unless last_command
			last_command.arguments.join(' ')
		end

		#
		# For backward compatibility
		#
		def line=(line)
			raise ArgumentError, 'no command specified' unless last_command
			last_command.arguments.clear
			last_command.arguments << line.split(' ')
		end


		def append(line = nil, &block)<commit_msg>Just debug the message instead of raising. To support handlers without commands<commit_after>require 'easy_type/command_entry'
require 'easy_type/blank_slate'

module EasyType
	#
	# The command builder is a class that helps building an OS command sequence. You can specify 
	# a base command on creation. With the << you can add parameters and options in the order you would 
	# like. Sometimes you need to execute commands before and/or after the base command. The ScriptBuilder
	# supports this by using the `before` and `after` methods
	#
	class ScriptBuilder


		attr_reader :acceptable_commands, :binding

		def initialize(options = {}, &block)
			@entries ||= []
			@acceptable_commands = Array(options.fetch(:acceptable_commands) {[]})
			@binding = options[:binding]
			@context = BlankSlate.new
			if @binding
				CommandEntry.set_binding(@binding)
				copy_resource_info
			end
			@acceptable_commands.each do | command|
				@context.eigenclass.send(:define_method,command) do |*args|
					@entries[type] << CommandEntry.new(command, args)
				end
			end
			@context.type = :main
			@context.instance_eval(&block) if block
		end

		def entries(type = :main)
			@context.entries[type]
		end

		def default_command
			@acceptable_commands.first || ''
		end

		def last_command(type = :main)
			entries(type).last
		end

		def add(*args, &block)
			if block
				add_to_queue(:main, &block)
				nil
			else
				entries(:main) << CommandEntry.new(default_command, args) unless args == [nil] #special case
			end
		end

		def <<(line)
			Puppet.debug 'no command specified' unless last_command
			last_command.arguments << line if line
		end

		#
		# For backward compatibility
		#
		def line
			Puppet.debug 'no command specified' unless last_command
			last_command.arguments.join(' ')
		end

		#
		# For backward compatibility
		#
		def line=(line)
			Puppet.debug 'no command specified' unless last_command
			last_command.arguments.clear
			last_command.arguments << line.split(' ')
		end


		def append(line = nil, &block)
{'fraction_non_alphanumeric': 0.0947289905519642, 'fraction_numerical': 0.0, 'mean_word_length': 3.772241992882562, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6321316', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1190, 'n_words': 371}