Method: Mixin::Shell#version
- Defined in:
- lib/fox/interface/thor/mixin/shell.rb
#version(command) ⇒ String
Returns version string or empty if command not found / error
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/fox/interface/thor/mixin/shell.rb', line 113 def version command result = "" begin # Sanity raise ArgumentError, "Command not found" unless( which( command ) ) # Get usage help screen for command help = usage( command ) # Get version flag from help screen flag = version_flag( help ) return result if( flag.empty? ) # some stupid commands don't follow standard rules, e.g. bundle # Get actual version string = run( command + " " + flag ) # Guess way to extract and extract semver result = guess_version( .to_s ) rescue Exception => e say "(EE) " + e., :red result = "" end return result end |