Skip to content
Browse files

Modify --properties output to be a valid .jrubyrc file.

  • Loading branch information...
1 parent 5f211d5 commit d64fed2a32cd4dd0eb04025ea50822556eb2b818 @headius headius committed May 19, 2012
View
3 src/org/jruby/Main.java
@@ -59,6 +59,7 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.SimpleSampler;
+import org.jruby.util.cli.Options;
import org.jruby.util.cli.OutputStrings;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
@@ -162,7 +163,7 @@ private static void loadJRubyProperties(File dotfile) {
* exit flag. An exit flag means that Kernel.exit() has been explicitly
* invoked during the run.
*
- * @param staus The status value.
+ * @param status The status value.
*/
Status(int status) {
this.isExit = true;
View
1 src/org/jruby/RubyInstanceConfig.java
@@ -1212,6 +1212,7 @@ public boolean getLoadGemfile() {
private boolean shouldRunInterpreter = true;
private boolean shouldPrintUsage = false;
private boolean shouldPrintProperties=false;
+ private boolean dumpConfig=false;
private KCode kcode = KCode.NONE;
private String recordSeparator = "\n";
private boolean shouldCheckSyntax = false;
View
17 src/org/jruby/util/cli/Options.java
@@ -41,6 +41,23 @@
* of the built-in structure.
*/
public class Options {
+ public static String dump() {
+ StringBuilder sb = new StringBuilder("# JRuby configuration options with current values\n");
+ Category category = null;
+ for (Option option : _loadedOptions) {
+ if (category != option.category) {
+ category = option.category;
+ sb.append('\n').append(category.desc()).append('\n');
+ }
+ sb
+ .append(option.name)
+ .append('=')
+ .append(option.load())
+ .append('\n');
+ }
+ return sb.toString();
+ }
+
private static final List<Option> _loadedOptions = new ArrayList<Option>();
// This section holds all Options for JRuby. They will be listed in the
View
18 src/org/jruby/util/cli/OutputStrings.java
@@ -87,19 +87,23 @@ public static String getPropertyHelp() {
StringBuilder sb = new StringBuilder();
sb
- .append("These properties can be used to alter runtime behavior for perf or compatibility.\n")
- .append("Specify them by passing -X<property>=<value>\n")
- .append(" or if passing directly to Java, -Djruby.<property>=<value>\n")
- .append(" or put <property>=<value> in .jrubyrc\n");
+ .append("# These properties can be used to alter runtime behavior for perf or compatibility.\n")
+ .append("# Specify them by passing -X<property>=<value>\n")
+ .append("# or if passing directly to Java, -Djruby.<property>=<value>\n")
+ .append("# or put <property>=<value> in .jrubyrc\n")
+ .append("#\n# This dump is a valid .jrubyrc file of current settings.\n");
Category category = null;
for (Option property : Options.PROPERTIES) {
if (category != property.category) {
category = property.category;
- sb.append('\n').append(category).append(" settings:\n\n");
+ sb.append("\n################################################################################");
+ sb.append("\n# ").append(category).append(" settings");
+ sb.append("\n################################################################################\n\n");
}
- sb.append(" ").append(property.name).append('=').append(Arrays.toString(property.options)).append('\n');
- sb.append(" ").append(property.description).append(" Default is ").append(property.defval).append(".\n");
+ sb.append("# ").append(property.description).append('\n');
+ sb.append("# Options: ").append(Arrays.toString(property.options)).append(", Default: ").append(property.defval).append(".\n");
+ sb.append(property.name).append('=').append(property.load()).append("\n\n");
}
return sb.toString();

0 comments on commit d64fed2

Please sign in to comment.
Something went wrong with that request. Please try again.