Class: Gitvers::CLI
- Inherits:
-
Object
- Object
- Gitvers::CLI
- Defined in:
- lib/gitvers/cli.rb
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #usage ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
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 |
# File 'lib/gitvers/cli.rb', line 5 def initialize command = ARGV.shift.to_sym rescue nil rep = Repository.new(Dir.pwd) begin case command when :bump rep.bump(ARGV.shift) when :init if rep.versions.count > 0 puts "Repository already have a git tag #{rep.full_version}" else initial = ask("Please enter the initial version in the form X.Y.Z: ") rep.tag(initial) end when :show what = ARGV.shift case what when 'full' puts rep.full_version when 'short' puts rep.short_version when 'revision' puts rep.revision_number when 'shell' puts "GITVERS_REVISION=#{rep.revision_number}" puts "GITVERS_FULL=#{rep.full_version}" puts "GITVERS_SHORT=#{rep.short_version}" when 'lines' puts rep.revision_number puts rep.full_version puts rep.short_version else puts "Current version: #{rep.summary}\n\n" puts "All versions:" puts rep.versions.map {|l| " #{l}"} end else usage end rescue NoVersionError puts "No git tag, use `gitvers init` to create one." rescue InvaliVersionError => e puts e. end end |
Instance Method Details
#usage ⇒ Object
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/gitvers/cli.rb', line 53 def usage puts %|usage: gitvers <command> [<args>] Commands: init Create an initial git tag bump <step> Bump the version, step can be major, minor or patch bump <version> Bump the version to a specific destination version show [<what>] Display the current version 'What' can be: - full # x.y.z-commit - short # x.y.z - revision # revision - shell # output GITVERS_<name> variables - lines # output 3 lines with revision, full, short respectively Examples: gitvers bump major gitvers bump 1.3.4 | end |