Class: MrPoole::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/mr_poole/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



7
8
9
10
11
12
13
14
15
16
# File 'lib/mr_poole/cli.rb', line 7

def initialize(args)
  @helper = Helper.new
  @src_dir = @helper.ensure_jekyll_dir

  @params = args
  @config = @helper.config

  ext = @config.default_extension || 'md'
  @commands = Commands.new(ext)
end

Instance Method Details

#execute(action) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mr_poole/cli.rb', line 18

def execute(action)
  case action
  when 'post' then handle_post
  when 'draft' then handle_draft
  when 'publish' then handle_publish
  when 'unpublish' then handle_unpublish
  when '--version' then @helper.version_statement
  when '-v' then @helper.version_statement
  else @helper.gen_usage
  end

  @helper.restore_orig_directory
end

#handle_draftObject



36
37
38
# File 'lib/mr_poole/cli.rb', line 36

def handle_draft
  do_create('draft')
end

#handle_postObject



32
33
34
# File 'lib/mr_poole/cli.rb', line 32

def handle_post
  do_create('post')
end

#handle_publishObject



40
41
42
# File 'lib/mr_poole/cli.rb', line 40

def handle_publish
  do_move('publish')
end

#handle_unpublishObject



44
45
46
# File 'lib/mr_poole/cli.rb', line 44

def handle_unpublish
  do_move('unpublish')
end