Permalink
Browse files

added -noconfig:print and -precompiler:print options

  • Loading branch information...
1 parent d25ee4e commit 7e727c8eec1f23f7d3f30dd421163eccf286b3a4 @oleg-shilo committed Jan 12, 2017
Showing with 43 additions and 4 deletions.
  1. +18 −3 Source/HelpProvider.cs
  2. +6 −1 Source/Utils.cs
  3. +19 −0 Source/csscript.cs
@@ -157,9 +157,12 @@ static AppArgs()
"(applicable for console clients only)");
switch2Help[noconfig] = new ArgInfo("-noconfig[:<file>]",
"Do not use default CS-Script config file or use alternative one.",
- "Value \"out\" of the <file> is reserved for creating the config file (css_config.xml) with the default settings.\n" +
+ "Value \"out\" of the <file> is reserved for creating the config file (css_config.xml) "+
+ "with the default settings in the current directory.\n" +
+ "Value \"print\" of the <file> is reserved for printing the default config file content.\n" +
"(e.g. " + AppInfo.appName + " -noconfig sample.cs\n" +
- AppInfo.appName + " -noconfig:c:\\cs-script\\css_VB.dat sample.vb)");
+ AppInfo.appName + " -noconfig:print > css_VB.xml\n"+
+ AppInfo.appName + " -noconfig:c:\\cs-script\\css_VB.xml sample.vb)");
switch2Help[@out] = new ArgInfo("-out[:<file>]",
"Forces the script to be compiled into a specific location.",
"Used only for very fine hosting tuning.\n" +
@@ -183,7 +186,8 @@ static AppArgs()
switch2Help[precompiler] = new ArgInfo("-precompiler[:<file 1>,<file N>]",
"Specifies custom precompiler. This can be either script or assembly file.",
"Alias - pc[:<file 1>,<file N>]\n" +
- "If no file(s) specified prints the code template for the custom precompiler.\n" +
+ "If no file(s) specified prints the code template for the custom precompiler. The spacial value 'print' has \n"+
+ "the same effect (e.g. "+ AppInfo.appName + " -pc:print).\n" +
"There is a special reserved word '" + CSSUtils.noDefaultPrecompilerSwitch + "' to be used as a file name.\n" +
"It instructs script engine to prevent loading any built-in precompilers \n" +
"like the one for removing shebang before the execution.\n" +
@@ -572,6 +576,17 @@ public static string BuildPrecompilerSampleCode()
builder.Append("{" + Environment.NewLine);
builder.Append(" public static bool Compile(ref string scriptCode, string scriptFile, bool isPrimaryScript, Hashtable context)" + Environment.NewLine);
builder.Append(" {" + Environment.NewLine);
+ builder.Append(" //The context Hashtable items are:" + Environment.NewLine);
+ builder.Append(" //- out context:" + Environment.NewLine);
+ builder.Append(" // NewDependencies" + Environment.NewLine);
+ builder.Append(" // NewSearchDirs" + Environment.NewLine);
+ builder.Append(" // NewReferences" + Environment.NewLine);
+ builder.Append(" // NewIncludes" + Environment.NewLine);
+ builder.Append(" //- in context:" + Environment.NewLine);
+ builder.Append(" // SearchDirs" + Environment.NewLine);
+ builder.Append(" // ConsoleEncoding" + Environment.NewLine);
+ builder.Append(" // CompilerOptions" + Environment.NewLine);
+ builder.Append(Environment.NewLine);
builder.Append(" //if new assemblies are to be referenced add them (see 'Precompilers' in the documentation)" + Environment.NewLine);
builder.Append(" //var newReferences = (List<string>)context[\"NewReferences\"];" + Environment.NewLine);
builder.Append(" //newReferences.Add(\"System.Xml.dll\");" + Environment.NewLine);
View
@@ -911,7 +911,7 @@ static internal int ParseAppArgs(string[] args, IScriptExecutor executor)
}
else if (Args.ParseValuedArg(arg, AppArgs.precompiler, AppArgs.pc, out argValue)) // -precompiler:file1,file2
{
- if (argValue != null)
+ if (argValue != null && argValue != "print")
{
options.preCompilers = argValue;
}
@@ -943,6 +943,11 @@ static internal int ParseAppArgs(string[] args, IScriptExecutor executor)
executor.CreateDefaultConfigFile();
options.processFile = false;
}
+ else if (argValue == "print")
+ {
+ executor.PrintDefaultConfig();
+ options.processFile = false;
+ }
else
options.altConfig = argValue;
}
View
@@ -110,6 +110,8 @@ internal interface IScriptExecutor
void ShowPrecompilerSample();
void CreateDefaultConfigFile();
+ void PrintSimplePrecompiler();
+ void PrintDefaultConfig();
void ShowSample();
@@ -2091,6 +2093,23 @@ public void CreateDefaultConfigFile()
print("The default config file has been created: " + file);
}
+ public void PrintSimplePrecompiler()
+ {
+
+ }
+
+ /// <summary>
+ /// Prints the config file default content.
+ /// </summary>
+ public void PrintDefaultConfig()
+ {
+ string file = Path.GetTempFileName();
+ new Settings().Save(file);
+ string config = File.ReadAllText(file);
+ File.Delete(file);
+ print(config);
+ }
+
/// <summary>
/// Show CS-Script version information.
/// </summary>

0 comments on commit 7e727c8

Please sign in to comment.