c66_login 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/c66_login +1 -1
- data/lib/c66_login/cli.rb +40 -34
- data/lib/c66_login/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 623663da352e2bc82b575e786d63db528f956227
|
4
|
+
data.tar.gz: 96c9b78911089d212034502bb7c47a8b55f1ebd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c82deff0d78be9030a6d8a84accdb437fe23661a7c1b5de03930d228bfb45be6fc2c3e39ed3a156b032559b919176e3f94df25eadd2137e2624310b8aa21f40b
|
7
|
+
data.tar.gz: 420d2c4e68bf7832166edf132c814a2611636f292686da53bfb8d6097e14435df41e50ff358ae9a700c0e864bcb3fb002653b28adeceed4ea8696672d019750f
|
data/bin/c66_login
CHANGED
data/lib/c66_login/cli.rb
CHANGED
@@ -3,46 +3,52 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
module C66Login
|
5
5
|
class Cli < Thor
|
6
|
-
desc "
|
6
|
+
desc "add ", "adds a new cloud66 account"
|
7
7
|
|
8
|
+
def add
|
9
|
+
puts "Warning: this process deletes your current cx.json file"
|
10
|
+
#enter name for account
|
11
|
+
puts "Enter this accounts email: "
|
12
|
+
email = $stdin.gets.chomp
|
13
|
+
|
14
|
+
File.delete("#{ENV['HOME']}/.cloud66/cx.json") if File.exists?("#{ENV['HOME']}/.cloud66/cx.json")
|
15
|
+
|
16
|
+
system "cx stacks"
|
17
|
+
|
18
|
+
FileUtils.cp("#{ENV['HOME']}/.cloud66/cx.json", "#{ENV['HOME']}/.cloud66/#{email}.json")
|
19
|
+
|
20
|
+
puts "created #{email}.json and logged in"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "login", "Login to another account"
|
8
24
|
def login
|
9
|
-
|
25
|
+
files = []
|
26
|
+
i = 0
|
27
|
+
indexes = []
|
28
|
+
puts "Found auth tokens: "
|
29
|
+
Dir.foreach("#{ENV['HOME']}/.cloud66") do |file|
|
30
|
+
next if file == '.' or file == '..' or file == 'cx.json'
|
31
|
+
puts "[#{i}] #{file}"
|
32
|
+
files << file
|
33
|
+
indexes << i
|
34
|
+
i += 1
|
35
|
+
end
|
36
|
+
|
37
|
+
if i == 0
|
38
|
+
puts "Couldn't find any auth files"
|
39
|
+
return false
|
40
|
+
end
|
10
41
|
|
11
42
|
while true do
|
12
|
-
puts "
|
13
|
-
|
14
|
-
|
15
|
-
case option
|
16
|
-
when "1"
|
17
|
-
#enter name for account
|
18
|
-
puts "Enter name for account: "
|
19
|
-
name = gets.chomp.methodize
|
20
|
-
puts "Enter auth_token: "
|
21
|
-
token = gets.chomp
|
22
|
-
File.open("#{ENV['HOME']}/.cloud66/#{name}.json", 'w+') {|f|
|
23
|
-
f.write("{\"AccessToken\":\"#{token}\",\"RefreshToken\":\"\",\"Expiry\":\"0001-01-01T00:00:00Z\",\"Extra\":null}")
|
24
|
-
puts "created #{name}.json"
|
25
|
-
}
|
26
|
-
when "2"
|
27
|
-
files = []
|
28
|
-
index = 0
|
29
|
-
puts "Found auth tokens: "
|
30
|
-
Dir.foreach("#{ENV['HOME']}/.cloud66") do |file|
|
31
|
-
next if file == '.' or file == '..' or file == 'cx.json'
|
32
|
-
puts "[#{index}] #{file}"
|
33
|
-
files << file
|
34
|
-
end
|
35
|
-
puts ""
|
36
|
-
puts "Select index to auth login with: "
|
37
|
-
file_index = Integer(gets.chomp)
|
38
|
-
FileUtils.cp("#{ENV['HOME']}/.cloud66/#{files[file_index]}", "#{ENV['HOME']}/.cloud66/cx.json")
|
39
|
-
puts "Logging in as: #{files[file_index]}"
|
40
|
-
exit
|
41
|
-
else
|
42
|
-
puts "Invalid option please try again"
|
43
|
-
end
|
43
|
+
puts "\nSelect index to auth login with: "
|
44
|
+
file_index = Integer($stdin.gets.chomp)
|
45
|
+
break if indexes.include?(file_index)
|
44
46
|
end
|
47
|
+
FileUtils.cp("#{ENV['HOME']}/.cloud66/#{files[file_index]}", "#{ENV['HOME']}/.cloud66/cx.json")
|
48
|
+
puts "Logging in as: #{files[file_index]}"
|
45
49
|
|
50
|
+
return true
|
46
51
|
end
|
52
|
+
|
47
53
|
end
|
48
54
|
end
|
data/lib/c66_login/version.rb
CHANGED