Sha256: 6ba0bd19061e7ecc556f065c87d7532557759f64c318ce353389e4247c34889a
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require "thor" module Licenza class CLI < Thor def initialize(*args) super @template = Template.new end class_option :year, type: :numeric, aliases: :y, desc: "The year to use. Default value is this year." class_option :name, type: :string, aliases: :n, desc: "The fullname to use. Default value is obtained from git." desc "show <LICENSE>", "Show a license text." def show(license) puts text(license) end desc "create <LICENSE>", "Create a license file." option :filename, type: :string, aliases: :f, desc: "The output filename. Default value is `LICENSE'." def create(license) filename = options[:filename] || DefaultSetting.filename open(filename, "w") do |f| f.puts text(license) end end desc "list", "See all available licenses." def list puts @template.licenses end desc "version", "Print the version." def version puts VERSION end no_tasks do def text(license) name = options[:name] || DefaultSetting.name year = options[:year] || DefaultSetting.year @template.render(license, name, year) rescue abort($!.message) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
licenza-0.2.1 | lib/licenza/cli.rb |
licenza-0.2.0 | lib/licenza/cli.rb |