# Rakefiledesc"Create Folder"task:create_folder,:folder_namedo|t,args|ifargs.folder_namefolder_name=args.folder_nameelsefolder_name=get_stdin("Enter a name for your folder: ")end# raise 產生錯誤,終止 taskraise"There does not input any folder name"unlessfolder_name# 使用 system 執行 linux 指令system"cd ~"# ruby FileUtils#mkdirmkdir"#{folder_name}"puts"created a folder #{folder_name}"enddefget_stdin(message)printmessageSTDIN.gets.chompend
# Add your own tasks in files placed in lib/tasks ending in .rake,# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.requireFile.expand_path('../config/application',__FILE__)Rails.application.load_tasks