switchcreds 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/switchcreds +15 -6
- data/lib/switchcreds/version.rb +1 -1
- data/lib/switchcreds.rb +3 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bdce7bfa143c82fe920a3d5a658aa3b424b6428
|
4
|
+
data.tar.gz: eea32d1570df39d3799b5f8295c41b195cdf4946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f67bb5a403692e6429074ba77484328f9f960986372fe046a99bed6a615566a15e336ce697269dd6ecf62f4f01a863451fe2cf2adca0590e1d076cc873f7dc39
|
7
|
+
data.tar.gz: 03c791501bc3d72f30bc2690839e11f5b1a7481a8ffb9bfda2539c7bcb9df83e6c3f8a3bdd9176d9bc349b2b53bba1ab3b9cf6faf3e060807067650ce46bd3b0
|
data/bin/switchcreds
CHANGED
@@ -3,6 +3,7 @@ require 'switchcreds'
|
|
3
3
|
require 'colorize'
|
4
4
|
require 'optparse'
|
5
5
|
require 'pp'
|
6
|
+
require 'fileutils'
|
6
7
|
|
7
8
|
class ParseOpts
|
8
9
|
def self.banner
|
@@ -24,12 +25,7 @@ class ParseOpts
|
|
24
25
|
options = {}
|
25
26
|
|
26
27
|
opt_parse = OptionParser.new do |opts|
|
27
|
-
opts.banner = "Usage: switchcreds
|
28
|
-
|
29
|
-
opts.on('-v','--version','Prints the current version of switchcreds') do |v|
|
30
|
-
puts SwitchCreds::VERSION.colorize(:default)
|
31
|
-
exit
|
32
|
-
end
|
28
|
+
opts.banner = "Usage: switchcreds -s\nOptions: switchcreds [options]"
|
33
29
|
|
34
30
|
opts.on('-h','--help','Shows help') do
|
35
31
|
banner
|
@@ -45,6 +41,15 @@ class ParseOpts
|
|
45
41
|
options[:switch] = s
|
46
42
|
end
|
47
43
|
|
44
|
+
opts.on('-v','--version','Prints the current version of switchcreds') do |v|
|
45
|
+
puts SwitchCreds::VERSION.colorize(:default)
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('-w','--which','Displays creds currently in use') do |w|
|
50
|
+
options[:which] = w
|
51
|
+
end
|
52
|
+
|
48
53
|
end
|
49
54
|
|
50
55
|
opt_parse.parse!(args)
|
@@ -69,3 +74,7 @@ end
|
|
69
74
|
if options[:switch]
|
70
75
|
SwitchCreds::switch_creds
|
71
76
|
end
|
77
|
+
|
78
|
+
if options[:which]
|
79
|
+
SwitchCreds::which_creds()
|
80
|
+
end
|
data/lib/switchcreds/version.rb
CHANGED
data/lib/switchcreds.rb
CHANGED
@@ -3,7 +3,7 @@ require "os"
|
|
3
3
|
|
4
4
|
module SwitchCreds
|
5
5
|
def self.get_creds
|
6
|
-
# detect the OS and user to find the .aws directory
|
6
|
+
# detect the OS and user to find the .aws/ directory
|
7
7
|
if OS.mac?
|
8
8
|
$user = Dir.home[7, Dir.home.length].to_s
|
9
9
|
elsif OS.linux?
|
@@ -11,7 +11,7 @@ module SwitchCreds
|
|
11
11
|
elsif OS.windows?
|
12
12
|
$user = Dir.home[9, Dir.home.length].to_s
|
13
13
|
else
|
14
|
-
puts "ERROR:".colorize(:red) + " Neither WINDOWS nor
|
14
|
+
puts "ERROR:".colorize(:red) + " Neither WINDOWS, MAC, nor LINUX OS detected.\n Unable to proceed."
|
15
15
|
end
|
16
16
|
dir = Dir.entries("/Users/#{$user}/.aws")
|
17
17
|
creds = []
|
@@ -44,7 +44,7 @@ module SwitchCreds
|
|
44
44
|
puts "\n"
|
45
45
|
end
|
46
46
|
|
47
|
-
def which_creds
|
47
|
+
def self.which_creds
|
48
48
|
creds = get_creds
|
49
49
|
creds.each do |cred|
|
50
50
|
if FileUtils.compare_file("/Users/#{$user}/.aws/credentials", "/Users/#{$user}/.aws/credentials_#{cred}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchcreds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Laflamme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fileutils
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: SwitchCreds is a simple gem that allows you to switch back and forth
|
84
98
|
between different Amazon Web Services (AWS) accounts via the command line. This
|
85
99
|
is achieved by automatically updating your ~/.aws/credentials file to point your
|