summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'instr-to-kodkod/src/Parameters.java')
-rw-r--r--instr-to-kodkod/src/Parameters.java79
1 files changed, 68 insertions, 11 deletions
diff --git a/instr-to-kodkod/src/Parameters.java b/instr-to-kodkod/src/Parameters.java
index d3bc0f1..7c80474 100644
--- a/instr-to-kodkod/src/Parameters.java
+++ b/instr-to-kodkod/src/Parameters.java
@@ -7,7 +7,8 @@ public class Parameters
private final List<String> model_files;
private final List<String> map_files;
private final String property_file;
- private final String var_prefix;
+ private final String output_file;
+ private final boolean be_verbose;
private final boolean are_valid;
@@ -17,12 +18,14 @@ public class Parameters
(
"Instr-to-kodkod\n"
+ "USAGE:\n"
- + "\tjava Main <VAR_PREFIX> <FILES>+\n"
+ + "\tjava Main <OUTPUT_FILE> <FILES|OPTIONS>+\n"
+ "PARAMETERS:\n"
- + "\t- <VAR_PREFIX>\tPrefix for anonymous variables (e.g. \"_anon_\").\n"
+ + "\t- <OUTPUT_FILE>\tFile to write the solutions in.\n"
+ "\t- <FILES>\tList of files to be loaded.\n"
+ + "OPTIONS:\n"
+ + "\t- -v|--verbose\tPrint informative messages to STDOUT.\n"
+ "NOTES:\n"
- + "\t- One, single, property file MUST be in <FILES>.\n"
+ + "\t- Exactly one property file must be in <FILES>.\n"
+ "\t- Property files have a \".pro\" extension.\n"
+ "\t- Model files have a \".mod\" extension.\n"
+ "\t- Level files have a \".lvl\" extension.\n"
@@ -31,23 +34,26 @@ public class Parameters
);
}
- public Parameters (String... args)
+ public Parameters (final String... args)
{
- boolean has_pro_file, has_error;
+ boolean has_pro_file, has_error, should_be_verbose;
String prop_file;
level_files = new ArrayList<String>();
model_files = new ArrayList<String>();
map_files = new ArrayList<String>();
+ should_be_verbose = false;
+
if (args.length < 2)
{
print_usage();
property_file = new String();
- var_prefix = new String();
+ output_file = new String();
are_valid = false;
+ be_verbose = false;
return;
}
@@ -55,7 +61,48 @@ public class Parameters
has_pro_file = false;
has_error = false;
- var_prefix = args[0];
+ output_file = args[0];
+
+ if
+ (
+ (output_file.equals("-v") || output_file.equals("--verbose"))
+ /* || ... */
+ )
+ {
+ print_usage();
+
+ System.err.println
+ (
+ "[F] An option was found in lieu of the output file."
+ );
+
+ System.exit(-1);
+ }
+
+ if
+ (
+ output_file.endsWith(".lvl")
+ || output_file.endsWith(".mod")
+ || output_file.endsWith(".map")
+ || output_file.endsWith(".pro")
+ )
+ {
+ print_usage();
+
+ System.err.println
+ (
+ "[F] The output file has an extension that could be used in an"
+ + " input file. It is most likely that you did not indicate an"
+ + " output file, meaning that one of the input files was about to"
+ + " be written over. So likely, in fact, that we'll abort here. The"
+ + " output file you indicated was \""
+ + output_file
+ + "\"."
+ );
+
+ System.exit(-1);
+ }
+
prop_file = new String();
for (int i = 1; i < args.length; ++i)
@@ -65,7 +112,7 @@ public class Parameters
level_files.add(args[i]);
}
else if (args[i].endsWith(".mod"))
- {
+ {
model_files.add(args[i]);
}
else if (args[i].endsWith(".map"))
@@ -93,6 +140,10 @@ public class Parameters
prop_file = args[i];
}
}
+ else if (output_file.equals("-v") || output_file.equals("--verbose"))
+ {
+ should_be_verbose = true;
+ }
else
{
System.err.println
@@ -115,6 +166,7 @@ public class Parameters
has_error = true;
}
+ be_verbose = should_be_verbose;
are_valid = !has_error;
}
@@ -138,9 +190,14 @@ public class Parameters
return property_file;
}
- public String get_variables_prefix ()
+ public String get_output_file ()
+ {
+ return output_file;
+ }
+
+ public boolean be_verbose ()
{
- return var_prefix;
+ return be_verbose;
}
public boolean are_valid ()