Class: CommitLive::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/commit-live/cli.rb

Instance Method Summary collapse

Instance Method Details

#helloObject



12
13
14
# File 'lib/commit-live/cli.rb', line 12

def hello()
	puts "Hello World!"
end

#open(track_slug) ⇒ Object



46
47
48
# File 'lib/commit-live/cli.rb', line 46

def open(track_slug)
	CommitLive::Open.new().openALesson(track_slug)
end

#resetObject



41
42
43
# File 'lib/commit-live/cli.rb', line 41

def reset()
	CommitLive::User.new().confirmAndReset
end

#setup(retries: 5) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/commit-live/cli.rb', line 17

def setup(retries: 5)
	# Check if token already present
	, password = CommitLive::NetrcInteractor.new().read
	if .nil? || password.nil?
		print 'Enter User-ID here and press [ENTER]: '
		 = STDIN.gets.chomp
		if .empty?
			puts "No User-ID provided."
			exit
		end
		print 'Enter Access token here and press [ENTER]: '
		password = STDIN.gets.chomp
		if password.empty?
			puts "No token provided."
			exit
		end
	end
	# Check if token is valid
	user = CommitLive::User.new()
	user.validate(, password)
	user.setDefaultWorkspace
end

#submit(track_slug) ⇒ Object



51
52
53
# File 'lib/commit-live/cli.rb', line 51

def submit(track_slug)
	CommitLive::Submit.new().run(track_slug)
end

#test(track_slug) ⇒ Object



56
57
58
# File 'lib/commit-live/cli.rb', line 56

def test(track_slug)
	CommitLive::Test.new(track_slug).run
end

#versionObject



61
62
63
# File 'lib/commit-live/cli.rb', line 61

def version
	puts CommitLive::Cli::VERSION
end