class Fontist::CLI
Constants
- ERROR_TO_STATUS
- STATUS_FONTCONFIG_FILE_NOT_FOUND
- STATUS_FONTCONFIG_NOT_FOUND
- STATUS_FONTIST_VERSION_ERROR
- STATUS_FONT_INDEX_CORRUPTED
- STATUS_FORMULA_NOT_FOUND
- STATUS_INVALID_CONFIG_ATTRIBUTE
- STATUS_LICENSING_ERROR
- STATUS_MAIN_REPO_NOT_FOUND
- STATUS_MANIFEST_COULD_NOT_BE_FOUND_ERROR
- STATUS_MANIFEST_COULD_NOT_BE_READ_ERROR
- STATUS_MANUAL_FONT_ERROR
- STATUS_MISSING_FONT_ERROR
- STATUS_NON_SUPPORTED_FONT_ERROR
- STATUS_REPO_COULD_NOT_BE_UPDATED
- STATUS_REPO_NOT_FOUND
- STATUS_SIZE_LIMIT_ERROR
- STATUS_SUCCESS
- STATUS_UNKNOWN_ERROR
Public Class Methods
Public Instance Methods
Source
# File lib/fontist/cli.rb, line 217 def create_formula(url) handle_class_options(options) require "fontist/import/create_formula" name = Fontist::Import::CreateFormula.new(url, options).call Fontist.ui.say("#{name} formula has been successfully created") success end
Source
# File lib/fontist/cli.rb, line 121 def install(font) handle_class_options(options) confirmation = options[:accept_all_licenses] ? "yes" : "no" Fontist::Font.install(font, options.merge(confirmation: confirmation)) success rescue Fontist::Errors::GeneralError => e handle_error(e) end
Source
# File lib/fontist/cli.rb, line 157 def list(font = nil) handle_class_options(options) formulas = Fontist::Font.list(font) print_list(formulas) success rescue Fontist::Errors::GeneralError => e handle_error(e) end
Source
# File lib/fontist/cli.rb, line 195 def manifest_install(manifest) handle_class_options(options) instance = Fontist::Manifest.from_file(manifest) paths = instance.install( confirmation: options[:accept_all_licenses] ? "yes" : "no", hide_licenses: options[:hide_licenses], ) print_yaml(paths.to_hash) success rescue Fontist::Errors::GeneralError => e handle_error(e) end
Source
# File lib/fontist/cli.rb, line 179 def manifest_locations(manifest) handle_class_options(options) paths = Fontist::Manifest.from_file(manifest, locations: true) print_yaml(paths.to_hash) success rescue Fontist::Errors::GeneralError => e handle_error(e) end
Source
# File lib/fontist/cli.rb, line 232 def rebuild_index handle_class_options(options) Fontist::Index.rebuild Fontist.ui.say("Formula index has been rebuilt.") STATUS_SUCCESS end
Source
# File lib/fontist/cli.rb, line 143 def status(font = nil) handle_class_options(options) paths = Fontist::Font.status(font) if paths.empty? return error("No font is installed.", STATUS_MISSING_FONT_ERROR) end success rescue Fontist::Errors::GeneralError => e handle_error(e) end
Source
# File lib/fontist/cli.rb, line 131 def uninstall(font) handle_class_options(options) fonts_paths = Fontist::Font.uninstall(font) Fontist.ui.success("These fonts are removed:") Fontist.ui.success(fonts_paths.join("\n")) success rescue Fontist::Errors::GeneralError => e handle_error(e) end
Source
# File lib/fontist/cli.rb, line 167 def update handle_class_options(options) Formula.update_formulas_repo Fontist.ui.success("Formulas have been successfully updated.") success rescue Fontist::Errors::RepoCouldNotBeUpdatedError => e Fontist.ui.error(e.message) STATUS_REPO_COULD_NOT_BE_UPDATED end
Source
# File lib/fontist/cli.rb, line 67 def version handle_class_options(options) Fontist.ui.say("fontist: #{Fontist::VERSION}") # Show formulas repository information if available if Dir.exist?(Fontist.formulas_repo_path) begin require "git" repo = Git.open(Fontist.formulas_repo_path) repo_url = repo.config["remote.origin.url"] || Fontist.formulas_repo_url branch = repo.current_branch # Use execute.first for git gem ~> 4.0 compatibility log_entry = repo.log(1).execute.first revision = log_entry.sha[0..6] updated = repo.gcommit(log_entry.sha).date.strftime("%Y-%m-%d") Fontist.ui.say("formulas:") Fontist.ui.say(" repo: #{repo_url}") Fontist.ui.say(" version: #{Fontist.formulas_version}") Fontist.ui.say(" branch: #{branch}") Fontist.ui.say(" commit: #{revision}") Fontist.ui.say(" updated: #{updated}") rescue StandardError => e Fontist.ui.debug("Could not read formulas repository info: #{e.message}") end end STATUS_SUCCESS end