Class: Octopress::New
Class Method Summary collapse
Methods inherited from Command
inherited, #init_with_program, subclasses
Class Method Details
.init_with_program(p) ⇒ Object
3 4 5 6 7 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/octopress/commands/new.rb', line 3 def self.init_with_program(p) p.command(:new) do |c| c.syntax 'new <PATH>' c.description 'Creates a new site with Jekyll and Octopress scaffolding at the specified path.' c.option 'force', '-f', '--force', 'Force creation even if path already exists.' c.option 'blank', '-b', '--blank', 'Creates scaffolding but with empty files.' c.action do |args, | if args.empty? c.logger.error "You must specify a path." puts c else Jekyll::Commands::New.process(args, ) Octopress::Scaffold.new(args, ).write end end c.command(:page) do |c| c.syntax 'page <PATH> [options]' c.description 'Add a new page to your Jekyll site.' c.option 'title', '-t', '--title TITLE', 'String to be added as the title in the YAML front-matter.' CommandHelpers. c CommandHelpers. c c.action do |args, | if args.empty? c.logger.error "Plese pass a path for your new page." puts c else ['path'] = args.first Page.new(Octopress.site(), ).write end end end c.command(:post) do |c| c.syntax 'post <TITLE> [options]' c.description 'Add a new post to your Jekyll site.' CommandHelpers. c c.option 'slug', '-s', '--slug SLUG', 'Use this slug in filename instead of sluggified post title.' c.option 'dir', '-D', '--dir DIR', 'Create post at _posts/DIR/.' CommandHelpers. c c.action do |args, | if args.empty? c.logger.error "Please pass a title for your new post." puts c else ['title'] = args.join(" ") Post.new(Octopress.site(), ).write end end end c.command(:draft) do |c| c.syntax 'draft <TITLE> [options]' c.description 'Add a new draft post to your Jekyll site.' CommandHelpers. c c.option 'slug', '-s', '--slug SLUG', 'Use this slug in filename instead of sluggified post title.' CommandHelpers. c c.action do |args, | if args.empty? c.logger.error "Plese pass a title for your new draft." puts c else ['title'] = args.join(" ") Draft.new(Octopress.site(), ).write end end end end end |