Sha256: e29ad67d47c52b52fdd31476b8fa99caffc0ee0610e43e09038abef63ce43de8

Contents?: true

Size: 1.3 KB

Versions: 14

Compression:

Stored size: 1.3 KB

Contents

module Fontist
  class RepoCLI < Thor
    desc "setup NAME URL",
         "Setup a custom fontist repo named NAME for the repository at URL " \
         "and fetches its formulas"
    def setup(name, url)
      Repo.setup(name, url)
      Fontist.ui.success(
        "Fontist repo '#{name}' from '#{url}' has been successfully set up.",
      )
      CLI::STATUS_SUCCESS
    end

    desc "update NAME", "Update formulas in a fontist repo named NAME"
    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)
    end

    desc "remove NAME", "Remove fontist repo named NAME"
    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

    desc "list", "List fontist repos"
    def list
      Repo.list.each do |name|
        Fontist.ui.say(name)
      end
      CLI::STATUS_SUCCESS
    end

    private

    def handle_repo_not_found(name)
      Fontist.ui.error("Fontist repo '#{name}' is not found.")
      CLI::STATUS_REPO_NOT_FOUND
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fontist-1.13.1 lib/fontist/repo_cli.rb
fontist-1.13.0 lib/fontist/repo_cli.rb
fontist-1.12.0 lib/fontist/repo_cli.rb
fontist-1.11.7 lib/fontist/repo_cli.rb
fontist-1.11.6 lib/fontist/repo_cli.rb
fontist-1.11.5 lib/fontist/repo_cli.rb
fontist-1.11.3 lib/fontist/repo_cli.rb
fontist-1.11.2 lib/fontist/repo_cli.rb
fontist-1.9.3 lib/fontist/repo_cli.rb
fontist-1.9.2 lib/fontist/repo_cli.rb
fontist-1.11.1 lib/fontist/repo_cli.rb
fontist-1.10.1 lib/fontist/repo_cli.rb
fontist-1.10.0 lib/fontist/repo_cli.rb
fontist-1.9.1 lib/fontist/repo_cli.rb