Sha256: 38178a059f2f38b76fd2aacd966c9c0187c256656253abdd1ccdeb71bce5b05e

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

module Fontist
  class RepoCLI < Thor
    include CLI::ClassOptions

    desc "setup NAME URL",
         "Setup a custom fontist repo named NAME for the repository at URL " \
         "and fetches its formulas"
    def setup(name, url)
      handle_class_options(options)
      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)
      handle_class_options(options)
      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)
      handle_class_options(options)
      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
      handle_class_options(options)
      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

10 entries across 10 versions & 1 rubygems

Version Path
fontist-1.15.1 lib/fontist/repo_cli.rb
fontist-1.15.0 lib/fontist/repo_cli.rb
fontist-1.14.6 lib/fontist/repo_cli.rb
fontist-1.14.5 lib/fontist/repo_cli.rb
fontist-1.14.4 lib/fontist/repo_cli.rb
fontist-1.14.3 lib/fontist/repo_cli.rb
fontist-1.14.2 lib/fontist/repo_cli.rb
fontist-1.14.1 lib/fontist/repo_cli.rb
fontist-1.14.0 lib/fontist/repo_cli.rb
fontist-1.13.2 lib/fontist/repo_cli.rb