Class: Learn::CLI

Inherits:
Object
  • Object
show all
Extended by:
Term::ANSIColor
Defined in:
lib/learn/cli.rb

Class Method Summary collapse

Class Method Details

.startObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/learn/cli.rb', line 7

def self.start
    filename = ARGV.pop

    #if the file doesn't exist, create it
    unless File.exists?(Learn::SETTINGS_PATH)
        print green, "Hi! It's time to register, this should only happen once!",reset
        print "\nAccount Number: "


        = gets.chomp
        if Learn::Student.register()
            print green, "Done, you're registered as a student", reset, "\n"
        else
            print red, "Couldn't register, check your internet collection and try again", reset, "\n"
        end
    end

    if filename and File.exists?("./#{filename}")
      contents = File.read("./#{filename}")
      Learn::Exercise.submit(filename, contents)
    else
      print red,  "Usage: learn ex<exercise_number>.rb", reset, "\n"
    end
end