|
1 | 1 | package org.jruby.util.cli; |
2 | 2 |
|
3 | 3 | import com.headius.options.Option; |
| 4 | +import org.jruby.RubyInstanceConfig; |
4 | 5 | import org.jruby.ext.rbconfig.RbConfigLibrary; |
5 | 6 | import org.jruby.platform.Platform; |
6 | 7 | import org.jruby.runtime.Constants; |
@@ -139,6 +140,36 @@ public static String getPropertyHelp() { |
139 | 140 | return sb.append(Option.formatOptions(Options.PROPERTIES)).toString(); |
140 | 141 | } |
141 | 142 |
|
| 143 | + /** |
| 144 | + * Produce a version string based on the given configuration. |
| 145 | + * |
| 146 | + * @param config the configuraton |
| 147 | + * @return a version string representing the given configuraton |
| 148 | + */ |
| 149 | + public static String getVersionString(RubyInstanceConfig config) { |
| 150 | + return String.format( |
| 151 | + "jruby %s (%s) %s %s %s %s on %s%s%s [%s-%s]", |
| 152 | + Constants.VERSION, |
| 153 | + Constants.RUBY_VERSION, |
| 154 | + Constants.COMPILE_DATE, |
| 155 | + Constants.REVISION.substring(0, 10), |
| 156 | + SafePropertyAccessor.getProperty("java.vm.name", "Unknown JVM"), |
| 157 | + SafePropertyAccessor.getProperty("java.vm.version", "Unknown JVM version"), |
| 158 | + SafePropertyAccessor.getProperty("java.runtime.version", SafePropertyAccessor.getProperty("java.version", "Unknown version")), |
| 159 | + Options.COMPILE_INVOKEDYNAMIC.load() ? " +indy" : " -indy", |
| 160 | + config.getCompileMode().shouldJIT() ? " +jit" : " -jit", |
| 161 | + RbConfigLibrary.getArchitecture(), |
| 162 | + RbConfigLibrary.getOSName() |
| 163 | + ); |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * Produce a version string containing only static values for JRuby and system properties. |
| 168 | + * |
| 169 | + * Use {@link #getVersionString(RubyInstanceConfig)} to reflect current runtime's parameters. |
| 170 | + * |
| 171 | + * @return a version string containing static information about the available JRuby version |
| 172 | + */ |
142 | 173 | public static String getVersionString() { |
143 | 174 | return String.format( |
144 | 175 | "jruby %s (%s) %s %s %s %s on %s%s%s [%s-%s]", |
|
0 commit comments