Class: Circle::CLI::App
- Inherits:
-
Thor
- Object
- Thor
- Circle::CLI::App
- Defined in:
- lib/circle/cli/app.rb
Constant Summary collapse
- CIRCLE_URL =
'https://circleci.com/account/api'- LOGIN_HELP =
<<-EOMSG 1. Press [enter], and you'll be taken CircleCI. 2. Enter a name for your new token. 3. Click 'Create new token'. 4. Come back to your prompt and paste in your new token. 5. Press enter to complete the process. EOMSG
- NO_TOKEN_MESSAGE =
<<-EOMSG CircleCI token hasn't been configured. Run the following command to login: $ circle login EOMSG
Instance Method Summary collapse
- #build ⇒ Object
- #cancel ⇒ Object
- #login ⇒ Object
- #open ⇒ Object
- #overview ⇒ Object
- #status ⇒ Object
- #token(value = nil) ⇒ Object
- #watch ⇒ Object
Instance Method Details
#build ⇒ Object
90 91 92 93 94 95 |
# File 'lib/circle/cli/app.rb', line 90 def build validate_repo! project.build! say "A build has been triggered.\n\n", :green invoke :status, [], watch: true end |
#cancel ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/circle/cli/app.rb', line 99 def cancel validate_repo! validate_latest! latest.cancel! unless latest.finished? invoke :status say "\nThe build has been cancelled.", :red unless latest.finished? end |
#login ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/circle/cli/app.rb', line 119 def login say LOGIN_HELP, :yellow ask set_color("\nPress [enter] to open CircleCI", :blue) Launchy.open(CIRCLE_URL) value = ask set_color('Enter your token:', :blue) repo.circle_token = value say "\nYour token has been set to '#{value}'.", :green end |
#open ⇒ Object
82 83 84 85 86 |
# File 'lib/circle/cli/app.rb', line 82 def open validate_repo! validate_latest! Launchy.open latest[:build_url] end |
#overview ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/circle/cli/app.rb', line 60 def overview validate_repo! abort! 'No recent builds.' if project.recent_builds.empty? watcher = Watcher.new do display_builds(project.recent_builds) end watcher.to_preload do project.clear_cache! project.recent_builds end if [:watch] watcher.poll([:poll]) else watcher.display end end |
#status ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/circle/cli/app.rb', line 32 def status validate_repo! validate_latest! watcher = Watcher.new do display_status end watcher.to_preload do project.clear_cache! project.latest.preload end if [:watch] watcher.poll([:poll]) else watcher.display end end |
#token(value = nil) ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'lib/circle/cli/app.rb', line 108 def token(value = nil) if value repo.circle_token = value elsif value = repo.circle_token say value else say NO_TOKEN_MESSAGE, :yellow end end |
#watch ⇒ Object
53 54 55 |
# File 'lib/circle/cli/app.rb', line 53 def watch invoke :status, [], watch: true end |