Added static parse method to CodeMenuEntryActions class

This commit is contained in:
Jaex 2016-07-29 21:04:10 +03:00
parent 6c0849ed5d
commit 7e69fb8955
2 changed files with 15 additions and 6 deletions

View file

@ -79,8 +79,6 @@ public string Run(string filePath)
}
else
{
string args = Args.Replace("%filepath%", '"' + filePath + '"').Replace("%input", '"' + filePath + '"');
if (!string.IsNullOrEmpty(OutputExtension))
{
newFilePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filePath), System.IO.Path.GetFileNameWithoutExtension(filePath));
@ -91,10 +89,9 @@ public string Run(string filePath)
}
newFilePath += OutputExtension;
args = args.Replace("%output", '"' + newFilePath + '"');
}
psi.Arguments = args;
psi.Arguments = CodeMenuEntryActions.Parse(Args, filePath, newFilePath);
}
if (HiddenWindow)

View file

@ -31,11 +31,23 @@ public class CodeMenuEntryActions : CodeMenuEntry
{
protected override string Prefix { get; } = "%";
public static readonly CodeMenuEntryActions FilePath = new CodeMenuEntryActions("input", Resources.ActionsCodeMenuEntry_FilePath_File_path);
public static readonly CodeMenuEntryActions OutputFilePath = new CodeMenuEntryActions("output", Resources.ActionsCodeMenuEntry_OutputFilePath_File_path_without_extension____Output_file_name_extension_);
public static readonly CodeMenuEntryActions input = new CodeMenuEntryActions("input", Resources.ActionsCodeMenuEntry_FilePath_File_path);
public static readonly CodeMenuEntryActions output = new CodeMenuEntryActions("output", Resources.ActionsCodeMenuEntry_OutputFilePath_File_path_without_extension____Output_file_name_extension_);
public CodeMenuEntryActions(string value, string description) : base(value, description)
{
}
public static string Parse(string pattern, string inputPath, string outputPath)
{
string result = pattern.Replace(input.ToPrefixString(), '"' + inputPath + '"');
if (!string.IsNullOrEmpty(outputPath))
{
result.Replace(output.ToPrefixString(), '"' + outputPath + '"');
}
return result;
}
}
}