<commit_before># 
# the file defines the base functionality of commands
# that let you initializing a project, create an empty directory of module, or clone
# from remote repository, show the info of this software version, help document, and so on
#

module Simrb
	class Scommand

		def run args = []
			@output = []
			cmd 	= args.empty? ? '' : args.shift
			if Scommand.private_method_defined? cmd
				self.send(cmd, args)
			else
				@output << ">> WARNING: No #{cmd} command found >>"
				help
			end
			Simrb.p(@output.empty? ? 'Implemented complete' : @output)
		end

		private

			# initialize a project directory
			#
			# == Example
			# 
			# 	$ simrb init myapp
			#
			# or, initialize directory and module at the same time with more arguments,
			# the simrb/system is from remote, the blog is generated by local,
			# details see the new and clone method
			#
			# 	$ simrb init myapp simrb/system blog
			#
			def init args
				app_name = args.empty? ? 'myapp' : args.shift 

				# generate module directories and files
				Dir.mkdir app_name
				Dir.chdir app_name

				Scfg[:init_root_path].each do | item |
					path = "#{Spath[item]}"
					Simrb::path_init path
				end

				# initialize scfg file
				data = {}
				Scfg[:init_scfg_item].each do | item |
					data[item] = Scfg[item]
				end
				Simrb.yaml_write('scfg', data)

				# create module if it is given,
				# get module from remote repository if it has the backslash,
				# other is created at local
				unless args.empty?
					args.each do | name |
						name.index("/") ? clone(args) : new(args)
					end
				end

				# initialize rubygem bundled
# 				mode = "develpment"
# 				if @args.include? '--dev'
# 					mode = "production"
# 				end
# 				system("bundle install --gemfile=#{@app_name}/apps/#{@module_name}#{@gemfile_path} --without=#{mode}")

				@output << "Initialized project complete"
			end

			# create a module, initialize default paths of file and directory
			#
			# == Example
			# 
			# 	$ simrb new blog
			#
			# or, more than one at same time
			# 	
			# 	$ simrb new blog cms test
			#
			def new args
				Simrb.root_dir_force

				args.each do | name |
					if Smodules.include? name
						@output << "The module #{name} is existing, not new it"
					else
						# create root dir of module
						Simrb::path_init "#{Spath[:module]}#{name}/"

						Dir.chdir "."

						# create sub dir of module 
						Scfg[:init_module_path].each do | item |
							path = "#{Spath[:module]}#{name}#{Spath[item]}"
							Simrb::path_init path
						end

						# write the content of module info
						text = [{ 'name' => name, 'author' => 'unknown', 'version' => '1.0.0' }]
						Simrb.yaml_write "#{Spath[:module]}#{name}#{Spath[:modinfo]}", text

						# write the content of .gitignore
						path = "#{Spath[:module]}#{name}#{Spath[:gitignore]}"
						File.open(path, "w+") do | f |
							f.write "*.swp\n*.gem\n*~"
						end
					end
				end

				@output << "Initialized module complete"
			end

			# clone a module from remote repository to local
			#
			# == Example
			# 
			# 	$ simrb clone simrb/system
			#
			# or, more than one at same time
			#
			# 	$ simrb clone simrb/system simrb/test
			#
			def clone args
				Simrb.root_dir_force

				args.each do | name |
					if Smodules.include? name
						@output << "The module #{name} is existing, not clone from remote"
					else
						path = "#{Scfg[:repo_source]}#{name[0]}.git"
						name = "#{Spath[:module]}#{name[0].split('/').last}"
						system("git clone #{path} #{name}")
					end
				end

				@output << "Cloned module complete"
			end

			# kill the current process of Simrb of that is running in background
			#
			# == Example
			#
			# 	$ simrb kill
			#
			def kill args = []
				s = `ps -ax | grep 'simrb start'`
				s = s.split("\n")[0].split(" ")[0]
# 				s = `cat #{Spath[:tmp_dir]}pid`.split("\n")[0]
# 				`rm #{Spath[:tmp_dir]}pid`

				system("kill #{s}")
				@output << "Killed the process #{s} of Simrb"
			end

			# display the basic inforamtion of current version of Simrb
			#
			# == Example
			#
			# 	$ simrb info
			#
			def info args = []
				require 'simrb/info'
				@output << Simrb::Info
			end

			# the help document
			#
			# == Example
			#
			# 	$ simrb help
			# 	$ simrb help 0
			#
			def help args = []
				require 'simrb/help'
				require 'simrb/docs'
				@output << Simrb.help(args)
			end

	end
end
<commit_msg>add a bash command that is a shortcut to start web server<commit_after># 
# the file defines the base functionality of commands
# that let you initializing a project, create an empty directory of module, or clone
# from remote repository, show the info of this software version, help document, and so on
#

module Simrb
	class Scommand

		def run args = []
			@output = []
			cmd 	= args.empty? ? '' : args.shift
			if Scommand.private_method_defined? cmd
				self.send(cmd, args)
			else
				@output << ">> WARNING: No #{cmd} command found >>"
				help
			end
			Simrb.p(@output.empty? ? 'Implemented complete' : @output)
		end

		private

			# initialize a project directory
			#
			# == Example
			# 
			# 	$ simrb init myapp
			#
			# or, initialize directory and module at the same time with more arguments,
			# the simrb/system is from remote, the blog is generated by local,
			# details see the new and clone method
			#
			# 	$ simrb init myapp simrb/system blog
			#
			def init args
				app_name = args.empty? ? 'myapp' : args.shift 

				# generate module directories and files
				Dir.mkdir app_name
				Dir.chdir app_name

				Scfg[:init_root_path].each do | item |
					path = "#{Spath[item]}"
					Simrb::path_init path
				end

				# initialize scfg file
				data = {}
				Scfg[:init_scfg_item].each do | item |
					data[item] = Scfg[item]
				end
				Simrb.yaml_write('scfg', data)

				# create module if it is given,
				# get module from remote repository if it has the backslash,
				# other is created at local
				unless args.empty?
					args.each do | name |
						name.index("/") ? clone(args) : new(args)
					end
				end

				# initialize rubygem bundled
# 				mode = "develpment"
# 				if @args.include? '--dev'
# 					mode = "production"
# 				end
# 				system("bundle install --gemfile=#{@app_name}/apps/#{@module_name}#{@gemfile_path} --without=#{mode}")

				@output << "Initialized project complete"
			end

			# create a module, initialize default paths of file and directory
			#
			# == Example
			# 
			# 	$ simrb new blog
			#
			# or, more than one at same time
			# 	
			# 	$ simrb new blog cms test
			#
			def new args
				Simrb.root_dir_force

				args.each do | name |
					if Smodules.include? name
						@output << "The module #{name} is existing, not new it"
					else
						# create root dir of module
						Simrb::path_init "#{Spath[:module]}#{name}/"

						Dir.chdir "."

						# create sub dir of module 
						Scfg[:init_module_path].each do | item |
							path = "#{Spath[:module]}#{name}#{Spath[item]}"
							Simrb::path_init path
						end

						# write the content of module info
						text = [{ 'name' => name, 'author' => 'unknown', 'version' => '1.0.0' }]
						Simrb.yaml_write "#{Spath[:module]}#{name}#{Spath[:modinfo]}", text

						# write the content of .gitignore
						path = "#{Spath[:module]}#{name}#{Spath[:gitignore]}"
						File.open(path, "w+") do | f |
							f.write "*.swp\n*.gem\n*~"
						end
					end
				end

				@output << "Initialized module complete"
			end

			# clone a module from remote repository to local
			#
			# == Example
			# 
			# 	$ simrb clone simrb/system
			#
			# or, more than one at same time
			#
			# 	$ simrb clone simrb/system simrb/test
			#
			def clone args
				Simrb.root_dir_force

				args.each do | name |
					if Smodules.include? name
						@output << "The module #{name} is existing, not clone from remote"
					else
						path = "#{Scfg[:repo_source]}#{name[0]}.git"
						name = "#{Spath[:module]}#{name[0].split('/').last}"
						system("git clone #{path} #{name}")
					end
				end

				@output << "Cloned module complete"
			end

			# kill the current process of Simrb of that is running in background
			#
			# == Example
			#
			# 	$ simrb kill
			#
			def kill args = []
				s = `ps -ax | grep 'simrb start'`
				s = s.split("\n")[0].split(" ")[0]
# 				s = `cat #{Spath[:tmp_dir]}pid`.split("\n")[0]
# 				`rm #{Spath[:tmp_dir]}pid`

				system("kill #{s}")
				@output << "Killed the process #{s} of Simrb"
			end

			# display the basic inforamtion of current version of Simrb
			#
			# == Example
			#
			# 	$ simrb info
			#
			def info args = []
				require 'simrb/info'
				@output << Simrb::Info
			end

			# the help document
			#
			# == Example
			#
			# 	$ simrb help
			# 	$ simrb help 0
			#
			def help args = []
				require 'simrb/help'
				require 'simrb/docs'
				@output << Simrb.help(args)
			end

			# add a command shortcut to bashrc file
			#
			# == Example
			#
			# 	$ simrb bash
			#
			# so, you can start the web server by command
			#
			# 	$ 3ss
			#
			def bash args = []
				`echo 'alias 3ss="simrb start"' >> ~/.bashrc`
				`source ~/.bashrc`
			end

	end
end

{'fraction_non_alphanumeric': 0.12944523470839261, 'fraction_numerical': 0.00218842324105482, 'mean_word_length': 2.3851851851851853, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 19, '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': '1409576', 'n_tokens_mistral': 4029, 'n_tokens_neox': 3104, 'n_words': 932}