Class: Jekyll::Commands::Algolia

Inherits:
Command
  • Object
show all
Defined in:
lib/jekyll/commands/algolia.rb

Overview

Registering the ‘jekyll algolia` command

Class Method Summary collapse

Class Method Details

.init_with_program(prog) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/jekyll/commands/algolia.rb', line 8

def init_with_program(prog)
  prog.command(:algolia) do |command|
    command.syntax 'algolia [options]'
    command.description 'Push your content to an Algolia index'
    # Document the options that can be passed from the CLI
    command.option 'config',
                   '--config CONFIG_FILE[,CONFIG_FILE2,...]',
                   Array,
                   'Custom configuration file'
    command.option 'dry_run',
                   '--dry-run',
                   '-n',
                   'Do a dry run, do not push records'
    command.option 'verbose',
                   '--verbose',
                   'Display more information on what is indexed'
    command.option 'force_settings',
                   '--force-settings',
                   'Force updating of the index settings'
    command.option 'future',
                   '--future',
                   'Index posts with a future date'
    command.option 'show_drafts',
                   '--drafts',
                   '-D',
                   'Index posts in the _drafts folder'

    command.action do |_, options|
      configuration = configuration_from_options(options)

      Jekyll::Algolia.init(configuration).run
    end
  end
end