Class: Michael::Commands::Auth
- Inherits:
-
Michael::Command
- Object
- Michael::Command
- Michael::Commands::Auth
- Defined in:
- lib/michael/commands/auth.rb
Instance Attribute Summary collapse
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
Instance Method Summary collapse
- #execute(out: $stdout) ⇒ Object
-
#initialize(options) ⇒ Auth
constructor
A new instance of Auth.
Methods inherited from Michael::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #pastel, #platform, #screen, #spinner, #which
Constructor Details
#initialize(options) ⇒ Auth
Returns a new instance of Auth.
13 14 15 16 |
# File 'lib/michael/commands/auth.rb', line 13 def initialize() @prompt = TTY::Prompt.new @options = end |
Instance Attribute Details
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
11 12 13 |
# File 'lib/michael/commands/auth.rb', line 11 def prompt @prompt end |
Instance Method Details
#execute(out: $stdout) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/michael/commands/auth.rb', line 18 def execute(out: $stdout) token = read_token unless Michael::Models::Github::TokenValidator.token_valid?(token) return out.puts 'Specified token is invalid' end unless Michael::Models::Github::TokenValidator.save_token(token) return out.puts 'Failed to save the token' end out.puts 'Token saved' end |