Class: QuickExam::CLI
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.define_exec_options ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/quick_exam/cli.rb', line 34 def self. option :shuffle_question, type: :string, aliases: ['-q'], default: 'true', desc: 'Shuffle the question', banner: 'true|false' option :shuffle_answer, type: :string, aliases: ['-a'], default: 'false', desc: 'Shuffle the answer', banner: 'true|false' option :same_answer, type: :string, aliases: ['-s'], default: 'false', desc: 'The same answer for all questionnaires', banner: 'false' option :f_ques, type: :string, aliases: ['-Q'], default: 'Q', desc: 'Question format. Just prefix the question', banner: 'Q' option :f_corr, type: :string, aliases: ['-C'], default: '!!!T', desc: 'Correct answer format', banner: '!!!T' option :count, type: :string, aliases: ['-c'], default: '2', desc: 'Number of copies to created', banner: '2' option :dest, type: :string, aliases: ['-d'], default: '', desc: 'File storage path after export', banner: '~/quick_exam_export/' end |
.help(shell, subcommand = false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/quick_exam/cli.rb', line 8 def self.help(shell, subcommand = false) list = printable_commands(true, subcommand) Thor::Util.thor_classes_in(self).each do |klass| list += klass.printable_commands(false) end # Remove this line to disable alphabetical sorting list.sort! { |a, b| a[0] <=> b[0] } # Add this line to remove the help-command itself from the output # list.reject! {|l| l[0].split[1] == 'help'} if defined?(@package_name) && @package_name shell.say "#{@package_name} commands:" else shell.say "Commands:" end shell.print_table(list, :indent => 2, :truncate => true) shell.say (shell) # Add this line if you want to print custom text at the end of your help output. # (similar to how Rails does it) shell.say 'All commands can be run with -h (or --help) for more information.' end |
Instance Method Details
#__print_version ⇒ Object
70 71 72 73 |
# File 'lib/quick_exam/cli.rb', line 70 def __print_version year = Time.now.year.to_s == '2020' ? '2020' : "2020 - #{Time.now.year}" puts "quick_exam #{QuickExam::VERSION} (latest) (c) #{year} Tang Quoc Minh [[email protected]]" end |
#export(file_path) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/quick_exam/cli.rb', line 46 def export(file_path) shuffle_question = [:shuffle_question] == 'true' ? true : false shuffle_answer = [:shuffle_answer] == 'true' ? true : false same_answer = [:same_answer] == 'true' ? true : false f_ques = [:f_ques] f_corr = [:f_corr] count = [:count].to_i dest = [:dest] paths_export = QuickExam::Export.run( file_path, shuffle_question: shuffle_question, shuffle_answer: shuffle_answer, count: count, dest: dest, f_ques: f_ques, f_corr: f_corr, same_answer: same_answer ) show_msg_after_export(paths_export) end |