Class: DotPlan::Command::Register
- Inherits:
-
Object
- Object
- DotPlan::Command::Register
- Defined in:
- lib/dotplan/command/register.rb
Class Method Summary collapse
Class Method Details
.register(options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dotplan/command/register.rb', line 23 def self.register() raise "No username provided".red unless [:username] raise "No password provided".red unless [:password] begin resource = RestClient::Resource.new("#{DotPlan::DOTPLAN_URL}/user/#{[:username]}", :Password => [:password]) response = resource.post nil, :Password => [:password] rescue => e response = JSON.parse(e.response) raise response["error"].red end credentials = JSON.parse(response.body) credentials end |
.run(*args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dotplan/command/register.rb', line 4 def self.run(*args) print "Desired username: " username = $stdin.gets.chomp print "Password: " system "stty -echo" password = $stdin.gets.chomp system "stty echo" print "\n" begin credentials = register(:username => username, :password => password) puts 'Registered! Run "dotplan auth" now.' rescue => e puts e end end |