Skip to content

Versioning Commands

mosop edited this page Dec 11, 2016 · 4 revisions

You can set a command's version with the .version method.

class Command < Cli::Command
  version "1.0.0"
end

To access the version string in a running context, use the #version method.

class Command < Cli::Command
  version "1.0.0"

  def run
    version # => "1.0.0"
  end
end

Version Inheritance

Without an explicit definition, a subcommand inherits its supercommand's version.

class Command < Cli::Supercommand
  version "1.1.0"

  command "specific"
  command "inherit"

  module Commands
    class Specific < Cli::Command
      version "1.0.0"

      def run
        version # => "1.0.0"
      end
    end

    class Inherit < Cli::Command
      def run
        version # => "1.1.0"
      end
    end
  end
end

Clone this wiki locally