Class: Fontist::RepoCLI
- Inherits:
-
Thor
- Object
- Thor
- Fontist::RepoCLI
- Includes:
- CLI::ClassOptions
- Defined in:
- lib/fontist/repo_cli.rb
Instance Method Summary collapse
- #info(name) ⇒ Object
- #list ⇒ Object
- #remove(name) ⇒ Object
- #setup(name, url) ⇒ Object
- #update(name) ⇒ Object
Methods included from CLI::ClassOptions
#handle_class_options, included, #log_level
Instance Method Details
#info(name) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/fontist/repo_cli.rb', line 58 def info(name) () info = Repo.info(name) Fontist.ui.say(info.to_s) CLI::STATUS_SUCCESS rescue Errors::RepoNotFoundError handle_repo_not_found(name) end |
#list ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/fontist/repo_cli.rb', line 49 def list () Repo.list.each do |name| Fontist.ui.say(name) end CLI::STATUS_SUCCESS end |
#remove(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fontist/repo_cli.rb', line 37 def remove(name) () Repo.remove(name) Fontist.ui.success( "Fontist repo '#{name}' has been successfully removed.", ) CLI::STATUS_SUCCESS rescue Errors::RepoNotFoundError handle_repo_not_found(name) end |
#setup(name, url) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fontist/repo_cli.rb', line 8 def setup(name, url) () result = Repo.setup(name, url) # setup returns false if user cancelled return CLI::STATUS_SUCCESS if result == false Fontist.ui.success( "Fontist repo '#{name}' from '#{url}' has been successfully set up.", ) CLI::STATUS_SUCCESS end |
#update(name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fontist/repo_cli.rb', line 22 def update(name) () Repo.update(name) Fontist.ui.success( "Fontist repo '#{name}' has been successfully updated.", ) CLI::STATUS_SUCCESS rescue Errors::RepoNotFoundError handle_repo_not_found(name) rescue Errors::RepoCouldNotBeUpdatedError => e Fontist.ui.error(e.) CLI::STATUS_REPO_COULD_NOT_BE_UPDATED end |