Class: GemContribute::CLI::Auth
- Inherits:
-
Object
- Object
- GemContribute::CLI::Auth
- Defined in:
- lib/gem_contribute/cli/auth.rb
Overview
‘gem-contribute auth <subcommand>` — Stage 2 entry point for OAuth.
Subcommands:
login — start device flow, poll for completion, persist the token
status — show whether a token is cached for github.com (and try to
validate it by hitting /user)
logout — drop the cached token for github.com
Constant Summary collapse
- USAGE =
<<~USAGE Usage: gem-contribute auth <subcommand> Subcommands: login Authenticate with GitHub via OAuth device flow. status Show whether you're authenticated. logout Remove the cached token for github.com. USAGE
- DEFAULT_HOST =
"github.com"
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, store: TokenStore.new, sleeper: ->(s) { Kernel.sleep(s) }, browser_opener: nil, clipper: nil) ⇒ Auth
constructor
A new instance of Auth.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, store: TokenStore.new, sleeper: ->(s) { Kernel.sleep(s) }, browser_opener: nil, clipper: nil) ⇒ Auth
Returns a new instance of Auth.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gem_contribute/cli/auth.rb', line 24 def initialize(stdout: $stdout, stderr: $stderr, store: TokenStore.new, sleeper: ->(s) { Kernel.sleep(s) }, browser_opener: nil, clipper: nil) @stdout = stdout @stderr = stderr @store = store @sleeper = sleeper @browser_opener = browser_opener || method(:default_browser_opener) @clipper = clipper || method(:default_clipper) end |
Instance Method Details
#run(argv) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gem_contribute/cli/auth.rb', line 35 def run(argv) case argv.shift when "login" then login when "status" then status when "logout" then logout when nil, "help", "-h", "--help" @stdout.puts USAGE 0 else @stderr.puts "gem-contribute: unknown auth subcommand" @stderr.puts USAGE 2 end end |