feat(verbose): Add --verbose flag
				
					
				
			This commit is contained in:
		
							parent
							
								
									7b491e23af
								
							
						
					
					
						commit
						f2d57d6902
					
				| @ -20,12 +20,13 @@ class AlgoliaSearchJekyll < Jekyll::Command | |||||||
|           add_build_options(subcommand) |           add_build_options(subcommand) | ||||||
| 
 | 
 | ||||||
|           subcommand.action do |args, options| |           subcommand.action do |args, options| | ||||||
|             @config = configuration_from_options(options) |  | ||||||
| 
 |  | ||||||
|             default_options = { |             default_options = { | ||||||
|               'dry_run' => false |               'dry_run' => false, | ||||||
|  |               'verbose' => false | ||||||
|             } |             } | ||||||
|             options = default_options.merge(options) |             options = default_options.merge(options) | ||||||
|  |             @config = configuration_from_options(options) | ||||||
|  | 
 | ||||||
|             AlgoliaSearchJekyllPush.init_options(args, options, @config) |             AlgoliaSearchJekyllPush.init_options(args, options, @config) | ||||||
|                                    .jekyll_new(@config) |                                    .jekyll_new(@config) | ||||||
|                                    .process |                                    .process | ||||||
| @ -47,6 +48,8 @@ class AlgoliaSearchJekyll < Jekyll::Command | |||||||
|                      'Index posts that were marked as unpublished' |                      'Index posts that were marked as unpublished' | ||||||
|       command.option 'dry_run', '--dry-run', '-n', |       command.option 'dry_run', '--dry-run', '-n', | ||||||
|                      'Do a dry run, do not push records' |                      'Do a dry run, do not push records' | ||||||
|  |       command.option 'verbose', '--verbose', | ||||||
|  |                      'Display more information on what is indexed' | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ class AlgoliaSearchJekyllPush < Jekyll::Command | |||||||
|       @args = args |       @args = args | ||||||
|       @options = options |       @options = options | ||||||
|       @config = config |       @config = config | ||||||
|  |       @is_verbose = @config['verbose'] | ||||||
| 
 | 
 | ||||||
|       # Allow for passing index name on the command line |       # Allow for passing index name on the command line | ||||||
|       index_name = args[0] |       index_name = args[0] | ||||||
| @ -57,8 +58,10 @@ class AlgoliaSearchJekyllPush < Jekyll::Command | |||||||
|       # on disk |       # on disk | ||||||
|       def site.write |       def site.write | ||||||
|         items = [] |         items = [] | ||||||
|  |         is_verbose = config['verbose'] | ||||||
|         each_site_file do |file| |         each_site_file do |file| | ||||||
|           next unless AlgoliaSearchJekyllPush.indexable?(file) |           next unless AlgoliaSearchJekyllPush.indexable?(file) | ||||||
|  |           Jekyll.logger.info "Extracting data from #{file.path}" if is_verbose | ||||||
|           new_items = AlgoliaSearchRecordExtractor.new(file).extract |           new_items = AlgoliaSearchRecordExtractor.new(file).extract | ||||||
|           next if new_items.nil? |           next if new_items.nil? | ||||||
| 
 | 
 | ||||||
| @ -107,7 +110,7 @@ class AlgoliaSearchJekyllPush < Jekyll::Command | |||||||
|     def push(items) |     def push(items) | ||||||
|       AlgoliaSearchCredentialChecker.new(@config).assert_valid |       AlgoliaSearchCredentialChecker.new(@config).assert_valid | ||||||
| 
 | 
 | ||||||
|       is_dry_run = @options['dry_run'] |       is_dry_run = @config['dry_run'] | ||||||
|       Jekyll.logger.info '=== DRY RUN ===' if is_dry_run |       Jekyll.logger.info '=== DRY RUN ===' if is_dry_run | ||||||
| 
 | 
 | ||||||
|       # Create a temporary index |       # Create a temporary index | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ require 'json' | |||||||
| class AlgoliaSearchRecordExtractor | class AlgoliaSearchRecordExtractor | ||||||
|   def initialize(file) |   def initialize(file) | ||||||
|     @file = file |     @file = file | ||||||
|  |     @config = file.site.config | ||||||
|     default_config = { |     default_config = { | ||||||
|       'record_css_selector' => 'p' |       'record_css_selector' => 'p' | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user