Sha256: e367641fc796f68d7cb02055130169a3a1d48234aeb73a4df29016b4df3388ea

Contents?: true

Size: 1.79 KB

Versions: 9

Compression:

Stored size: 1.79 KB

Contents

#!/usr/bin/env ruby
# encoding: utf-8

# follow symlink
base   = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
libdir = File.expand_path(File.join(File.dirname(base), "..", "lib"))

# because of system installation, there is bin/../lib, but not bin/../lib/pupu
if File.directory?(File.join(libdir, "pupu"))
  $:.unshift(libdir) unless $:.include?(libdir)
end

require "pupu/cli"

# helpers
def usage
<<-HELP
=== Usage ===
pupu install [pupu] [-f|--force]
pupu uninstall [pupu]
pupu reinstall [pupu]
pupu update [pupu|all]
pupu list
pupu check
pupu search [pattern]
pupu create [name]
     --media-root=media
HELP
end

# main loop
begin
  case ARGV.shift
  when "install"
    Pupu::CLI.new(ARGV).install
  when "uninstall", "remove"
    Pupu::CLI.new(ARGV).uninstall
  when "reinstall"
    Pupu::CLI.new(ARGV, force: true).install
  when "update"
    Pupu::CLI.new(ARGV).update
  when "list" # list all pupus
    Pupu::CLI.new(ARGV).list
  when "check" # check setup & if you are in the right directory
    Pupu::CLI.new(ARGV).check || abort("File config/pupu.rb doesn't exist or can't be loaded")
  when "search"
    Pupu::CLI.new(ARGV).search(ARGV.first)
  when "create"
    begin
      require "simple-templater"
    rescue LoadError
      abort "You have to install simple-templater first!"
    end
    path = File.expand_path(File.join(File.dirname(base), "..", "stubs", "pupu"))
    generator = SimpleTemplater::GeneratorSet.new(:pupu, path)
    begin
      generator.run(ARGV)
    rescue SimpleTemplater::TargetAlreadyExist => exception
      abort exception.message
    rescue Interrupt
      exit
    rescue Exception => exception
      abort "Exception #{exception.inspect} occured during running generator #{generator.inspect}\n#{exception.backtrace.join("\n")}"
    end
  else
    abort usage
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pupu-0.2.1 bin/pupu
pupu-0.2 bin/pupu
pupu-0.1 bin/pupu
pupu-0.0.5.5 bin/pupu
pupu-0.0.5.4 bin/pupu
pupu-0.0.5.3 bin/pupu
pupu-0.0.5.2 bin/pupu
pupu-0.0.5.1 bin/pupu
pupu-0.0.5 bin/pupu