Sha256: f5efc66a5c2d2e61af05f5ee7dcb62136a65ba336bfe5ffc31412297e434b978

Contents?: true

Size: 1.4 KB

Versions: 13

Compression:

Stored size: 1.4 KB

Contents

require 'thor'
require 'coursegen/templates'
require 'nanoc'
require './cg_config.rb' if File.exist? 'cg_config.rb'

module CourseGen
  class CLI < Thor
    include Thor::Actions

    desc "new COURSE", "Create a new course by calling nanoc. Argument is name of the COURSE"
    def new(course)
      run("nanoc create-site #{course}")
    end

    desc "prepare", "Update with the latest coursegen code and templates."
    def prepare
      check_valid_directory
      tplt = CourseGen::Templates.new
      tplt.generate_all
    end

    desc "compile", "build the course and put resultant site into output directory"
    def compile
      run("nanoc compile")
    end

    desc "serve", "start local web server to test the course web site"
    def serve
      run("nanoc view")
    end

    desc "reset", "reset all generated content to bring the course back to a base state."
    def reset
      run "rm -frd tmp"
      run "rm -frd output"
    end

    desc "view", "view course site locally in browser"
    def view
      run "open http://0.0.0.0:3000"
    end

    desc "deploy", "Deploy course to S3"
    def deploy
      run "s3cmd sync --delete-removed output/ s3://#{AWS_BUCKET}/"
    end

    no_commands do
      def check_valid_directory
        if CourseGen::Templates.new.valid_cg_directory?
          say("Valid cg directory")
        else
          error("Invalid cg directory")
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
coursegen-0.8.3 lib/coursegen/cli.rb
coursegen-0.8.2 lib/coursegen/cli.rb
coursegen-0.8.1 lib/coursegen/cli.rb
coursegen-0.7.7 lib/coursegen/cli.rb
coursegen-0.7.6 lib/coursegen/cli.rb
coursegen-0.7.5 lib/coursegen/cli.rb
coursegen-0.7.4 lib/coursegen/cli.rb
coursegen-0.7.3 lib/coursegen/cli.rb
coursegen-0.7.2 lib/coursegen/cli.rb
coursegen-0.7.1 lib/coursegen/cli.rb
coursegen-0.7.0 lib/coursegen/cli.rb
coursegen-0.5.0 lib/coursegen/cli.rb
coursegen-0.4.2 lib/coursegen/cli.rb