c66_login 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50bb813d18eba8b4faab97a287c085b00d877ac7
4
- data.tar.gz: 029a12c99a0ddf50c87c844e109ef7f0abaa126a
3
+ metadata.gz: 623663da352e2bc82b575e786d63db528f956227
4
+ data.tar.gz: 96c9b78911089d212034502bb7c47a8b55f1ebd3
5
5
  SHA512:
6
- metadata.gz: 20c4c109bafa374c7792fdb07653fff8853bc6c216fb74c4a934dc7202b9b951b0608b8cd5bb43e5b3ebd910da6cd010d13fd1c470424ebfbfefd6ef32eab3d6
7
- data.tar.gz: 4f477d1403824489430707d005e5963776c0099298d9af21718b57d9d800a335502793cf813d3ead6e3f014b12d6fe1d867c26b7152ffc9cb8f4665512ce51b3
6
+ metadata.gz: c82deff0d78be9030a6d8a84accdb437fe23661a7c1b5de03930d228bfb45be6fc2c3e39ed3a156b032559b919176e3f94df25eadd2137e2624310b8aa21f40b
7
+ data.tar.gz: 420d2c4e68bf7832166edf132c814a2611636f292686da53bfb8d6097e14435df41e50ff358ae9a700c0e864bcb3fb002653b28adeceed4ea8696672d019750f
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'c66_login'
3
3
 
4
- C66Login::Cli.new.login
4
+ C66Login::Cli.start(ARGV)
@@ -3,46 +3,52 @@ require 'fileutils'
3
3
 
4
4
  module C66Login
5
5
  class Cli < Thor
6
- desc "hello NAME", "This will greet you"
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
- puts "Enter option"
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 "1. Enter new token"
13
- puts "2. Login another account"
14
- option = gets.chomp
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
@@ -1,3 +1,3 @@
1
1
  module C66Login
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c66_login
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Porter