Class: Fontist::CLI
  
  
  
Defined Under Namespace
  
    
      Modules: ClassOptions
    
  
    
  
  
    
      Constant Summary
      collapse
    
    
      
        - STATUS_SUCCESS =
          
        
 
        0
 
      
        - STATUS_UNKNOWN_ERROR =
          
        
 
        1
 
      
        - STATUS_NON_SUPPORTED_FONT_ERROR =
          
        
 
        2
 
      
        - STATUS_MISSING_FONT_ERROR =
          
        
 
        3
 
      
        - STATUS_LICENSING_ERROR =
          
        
 
        4
 
      
        - STATUS_MANIFEST_COULD_NOT_BE_FOUND_ERROR =
          
        
 
        5
 
      
        - STATUS_MANIFEST_COULD_NOT_BE_READ_ERROR =
          
        
 
        6
 
      
        - STATUS_FONT_INDEX_CORRUPTED =
          
        
 
        7
 
      
        - STATUS_REPO_NOT_FOUND =
          
        
 
        8
 
      
        - STATUS_MAIN_REPO_NOT_FOUND =
          
        
 
        9
 
      
        - STATUS_REPO_COULD_NOT_BE_UPDATED =
          
        
 
        10
 
      
        - STATUS_MANUAL_FONT_ERROR =
          
        
 
        11
 
      
        - STATUS_SIZE_LIMIT_ERROR =
          
        
 
        12
 
      
        - STATUS_FORMULA_NOT_FOUND =
          
        
 
        13
 
      
        - STATUS_FONTCONFIG_NOT_FOUND =
          
        
 
        14
 
      
        - STATUS_FONTCONFIG_FILE_NOT_FOUND =
          
        
 
        15
 
      
        - STATUS_FONTIST_VERSION_ERROR =
          
        
 
        15
 
      
        - STATUS_INVALID_CONFIG_ATTRIBUTE =
          
        
 
        16
 
      
        - ERROR_TO_STATUS =
          
        
 
        {
  Fontist::Errors::UnsupportedFontError => [STATUS_NON_SUPPORTED_FONT_ERROR],
  Fontist::Errors::MissingFontError => [STATUS_MISSING_FONT_ERROR],
  Fontist::Errors::SizeLimitError => [
    STATUS_SIZE_LIMIT_ERROR,
    :append,
    "Please specify higher `--size-limit`, or use the `--newest` or " \
    "`--smallest` options.",
  ],
  Fontist::Errors::ManualFontError => [STATUS_MANUAL_FONT_ERROR],
  Fontist::Errors::LicensingError => [STATUS_LICENSING_ERROR],
  Fontist::Errors::ManifestCouldNotBeFoundError => [STATUS_MANIFEST_COULD_NOT_BE_FOUND_ERROR,
                                                    :overwrite,
                                                    "Manifest could not be found."],
  Fontist::Errors::ManifestCouldNotBeReadError => [STATUS_MANIFEST_COULD_NOT_BE_READ_ERROR,
                                                   :overwrite,
                                                   "Manifest could not be read."],
  Fontist::Errors::FontIndexCorrupted => [STATUS_FONT_INDEX_CORRUPTED],
  Fontist::Errors::RepoNotFoundError => [STATUS_REPO_NOT_FOUND],
  Fontist::Errors::MainRepoNotFoundError => [STATUS_MAIN_REPO_NOT_FOUND],
  Fontist::Errors::FormulaNotFoundError => [STATUS_FORMULA_NOT_FOUND],
  Fontist::Errors::FontconfigNotFoundError => [STATUS_FONTCONFIG_NOT_FOUND],
  Fontist::Errors::FontconfigFileNotFoundError =>
    [STATUS_FONTCONFIG_FILE_NOT_FOUND],
  Fontist::Errors::FontistVersionError => [STATUS_FONTIST_VERSION_ERROR],
}.freeze 
      
    
  
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  extended, start
  
  
  
  
  
  
  
  
  
  #handle_class_options, included, #log_level
  
  
    Class Method Details
    
      
  
  
    .exit_on_failure?  ⇒ Boolean 
  
  
  
  
    
      
61
62
63 
     | 
    
      # File 'lib/fontist/cli.rb', line 61
def self.exit_on_failure?
  false
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    
      
181
182
183
184
185
186
187 
     | 
    
      # File 'lib/fontist/cli.rb', line 181
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
     | 
  
 
    
      
  
  
    #install(font)  ⇒ Object 
  
  
  
  
    
      
89
90
91
92
93
94
95
96 
     | 
    
      # File 'lib/fontist/cli.rb', line 89
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 
     | 
  
 
    
      
  
  
    #list(font = nil)  ⇒ Object 
  
  
  
  
    
      
122
123
124
125
126
127
128
129 
     | 
    
      # File 'lib/fontist/cli.rb', line 122
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 
     | 
  
 
    
      
  
  
    #manifest_install(manifest)  ⇒ Object 
  
  
  
  
    
      
160
161
162
163
164
165
166
167
168
169
170
171
172 
     | 
    
      # File 'lib/fontist/cli.rb', line 160
def manifest_install(manifest)
  handle_class_options(options)
  paths = Fontist::Manifest::Install.from_file(
    manifest,
    confirmation: options[:accept_all_licenses] ? "yes" : "no",
    hide_licenses: options[:hide_licenses]
  )
  print_yaml(paths)
  success
rescue Fontist::Errors::GeneralError => e
  handle_error(e)
end
     | 
  
 
    
      
  
  
    #manifest_locations(manifest)  ⇒ Object 
  
  
  
 
    
      
    
      
  
  
    #status(font = nil)  ⇒ Object 
  
  
  
 
    
      
  
  
    #uninstall(font)  ⇒ Object 
  
  
  
  
    
      
99
100
101
102
103
104
105
106
107 
     | 
    
      # File 'lib/fontist/cli.rb', line 99
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
     |