class Creq::Cli

Constants

CHK_ERR_MSGS

Public Class Methods

source_root() click to toggle source
# File lib/cli.rb, line 12
def self.source_root
  File.join Creq.root, "lib/assets"
end

Public Instance Methods

chk() click to toggle source
# File lib/cli.rb, line 72
def chk
  say "Checking repository for error..."

  result = check_repo
  if result.empty?
    puts "Everything is fine!"
    return
  end

  result.each { |k, v| puts "#{CHK_ERR_MSGS[k]}\n#{v.join("\n")}" }
end
doc() click to toggle source
# File lib/cli.rb, line 93
def doc
  create_doc(options[:query])
end
new(project) click to toggle source

long_desc File.read()

# File lib/cli.rb, line 25
def new(project)
  say "Creating a new project..."

  if Dir.exist?(project)
    error "Directory '#{project}' already exists. Operation aborted."
    return
  end

  Dir.mkdir(project)
  Dir.chdir(project) do
    init_project
    config = {project: project}

    say "Creating README ..."
    template('new/README.md.tt', File.join(Dir.pwd, 'README.md'), config)

    say "Creating #{project}.thor ..."
    template('new/creq.thor.tt', File.join(Dir.pwd, "#{project}.thor"), config)

    say "Copying content ..."
    copy_file('new/contents.md', File.join(Dir.pwd, "#{Settings.src}/contents.md"))

    say "Copying templates ..."
    directory('tt', File.join(Dir.pwd, 'tt'))

    say "Project '#{project}' created!"
  end
end
promo() click to toggle source
# File lib/cli.rb, line 55
def promo
  say "Copying promo project..."
  directory('promo', Dir.pwd)
end
pub() click to toggle source
# File lib/cli.rb, line 99
def pub
  puts "Format and options of output specified in `creq.yml`"
  pandoc(options[:query])
end
req(id, title = '') click to toggle source
# File lib/cli.rb, line 62
def req(id, title = '')
  result = ReqCommand.(id, title, options[:template])
  puts "File '#{result}' created successfully."
rescue  CreqCmdError => e
  puts e.message
rescue => e
  raise e
end
toc() click to toggle source
# File lib/cli.rb, line 86
def toc
  create_toc(options[:query])
end
version() click to toggle source
# File lib/cli.rb, line 19
def version
  puts "Creq v#{Creq::VERSION}"
end