Common CLI parameters extracted into a base class

This commit is contained in:
Andrey Breslav
2013-09-14 22:09:23 +04:00
parent 04101a91f3
commit f245d93eea
3 changed files with 48 additions and 76 deletions
@@ -0,0 +1,43 @@
package org.jetbrains.jet.cli;
import com.sampullara.cli.Argument;
import org.jetbrains.jet.cli.common.CompilerArguments;
public abstract class CommonCompilerArguments extends CompilerArguments {
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
public boolean tags;
@Argument(value = "verbose", description = "Enable verbose logging output")
public boolean verbose;
@Argument(value = "version", description = "Display compiler version")
public boolean version;
@Argument(value = "help", alias = "h", description = "Show help")
public boolean help;
@Override
public boolean isHelp() {
return help;
}
public void setHelp(boolean help) {
this.help = help;
}
@Override
public boolean isTags() {
return tags;
}
@Override
public boolean isVersion() {
return version;
}
@Override
public boolean isVerbose() {
return verbose;
}
public void setTags(boolean tags) {
this.tags = tags;
}
}
@@ -18,14 +18,14 @@ package org.jetbrains.jet.cli.js;
import com.sampullara.cli.Argument;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.cli.common.CompilerArguments;
import org.jetbrains.jet.cli.CommonCompilerArguments;
import org.jetbrains.k2js.facade.MainCallParameters;
/**
* NOTE: for now K2JSCompiler supports only minimal amount of parameters required to launch it from the plugin.
*/
public class K2JSCompilerArguments extends CompilerArguments {
public class K2JSCompilerArguments extends CommonCompilerArguments {
@Argument(value = "output", description = "Output file path")
public String outputFile;
@@ -41,42 +41,10 @@ public class K2JSCompilerArguments extends CompilerArguments {
@Argument(value = "target", description = "Generate js files for specific ECMA version (now support only ECMA 5)")
public String target;
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
public boolean tags;
@Argument(value = "verbose", description = "Enable verbose logging output")
public boolean verbose;
@Argument(value = "version", description = "Display compiler version")
public boolean version;
@Nullable
@Argument(value = "main", description = "Whether a main function should be called; either 'call' or 'noCall', default 'call' (main function will be auto detected)")
public String main;
@Argument(value = "help", alias = "h", description = "Show help")
public boolean help;
@Override
public boolean isHelp() {
return help;
}
@Override
public boolean isTags() {
return tags;
}
@Override
public boolean isVersion() {
return version;
}
@Override
public boolean isVerbose() {
return verbose;
}
@Override
public String getSrc() {
throw new IllegalStateException();
@@ -18,7 +18,7 @@
package org.jetbrains.jet.cli.jvm;
import com.sampullara.cli.Argument;
import org.jetbrains.jet.cli.common.CompilerArguments;
import org.jetbrains.jet.cli.CommonCompilerArguments;
import java.util.List;
@@ -26,7 +26,7 @@ import java.util.List;
* Command line arguments for the {@link K2JVMCompiler}
*/
@SuppressWarnings("UnusedDeclaration")
public class K2JVMCompilerArguments extends CompilerArguments {
public class K2JVMCompilerArguments extends CommonCompilerArguments {
// TODO ideally we'd unify this with 'src' to just having a single field that supports multiple files/dirs
@@ -82,18 +82,6 @@ public class K2JVMCompilerArguments extends CompilerArguments {
@Argument(value = "script", description = "evaluate script")
public boolean script;
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
public boolean tags;
@Argument(value = "verbose", description = "Enable verbose logging output")
public boolean verbose;
@Argument(value = "version", description = "Display compiler version")
public boolean version;
@Argument(value = "help", alias = "h", description = "show help")
public boolean help;
@Argument(value = "kotlinHome", description = "Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery")
public String kotlinHome;
@@ -113,15 +101,6 @@ public class K2JVMCompilerArguments extends CompilerArguments {
this.classpath = classpath;
}
@Override
public boolean isHelp() {
return help;
}
public void setHelp(boolean help) {
this.help = help;
}
public boolean isIncludeRuntime() {
return includeRuntime;
}
@@ -154,6 +133,7 @@ public class K2JVMCompilerArguments extends CompilerArguments {
this.outputDir = outputDir;
}
@Override
public String getSrc() {
return src;
}
@@ -162,25 +142,6 @@ public class K2JVMCompilerArguments extends CompilerArguments {
this.src = src;
}
@Override
public boolean isTags() {
return tags;
}
@Override
public boolean isVersion() {
return version;
}
@Override
public boolean isVerbose() {
return verbose;
}
public void setTags(boolean tags) {
this.tags = tags;
}
public void setNoStdlib(boolean noStdlib) {
this.noStdlib = noStdlib;
}