Skip to content

Commit db7dfd4

Browse files
committed
Add 'list' command to CLI
* This will list all the users you've added to your keys file with this gem.
1 parent f54ce8d commit db7dfd4

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

lib/github/auth/cli.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Github::Auth
33
class CLI
44
attr_reader :command, :usernames
55

6-
COMMANDS = %w(add remove)
6+
COMMANDS = %w(add remove list)
77

88
def initialize(argv)
99
@command = argv.shift
@@ -42,6 +42,10 @@ def remove
4242
"Removing #{keys.count} key(s) from '#{keys_file.path}'"
4343
end
4444

45+
def list
46+
puts "Added users: #{keys_file.github_users.join(', ')}"
47+
end
48+
4549
def on_keys_file(action, message)
4650
puts message
4751
rescue_keys_file_errors { keys_file.send action, keys }

spec/acceptance/github/auth/cli_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper'
2+
require 'support/capture_stdout'
23
require 'support/mock_github_server'
34
require 'github/auth'
45

@@ -32,5 +33,15 @@ def cli(argv)
3233

3334
keys_file.unlink
3435
end
36+
37+
it 'lists users from the keys file' do
38+
cli(%w(add chrishunt)).execute
39+
40+
output = capture_stdout do
41+
cli(%w(list)).execute
42+
end
43+
44+
expect(output).to include('chrishunt')
45+
end
3546
end
3647
end

0 commit comments

Comments
 (0)