diff --git a/README.md b/README.md index c0e0ed0..780ad2c 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,9 @@ Plus, `%DIR%` stands for current folder. ### Match - If not null, checks if current folder have the name (file or directory) -- Starts by ! for NOT have the name -- use ? and * for wildcard +- Splits conditions by **<&&>** +- Starts by **!** for reverse condition +- Use **?** and ***** for wildcard ### Icon diff --git a/ShellCommand/DataModel/DirectoryCommand.cs b/ShellCommand/DataModel/DirectoryCommand.cs index 5f3aacf..62abbdf 100644 --- a/ShellCommand/DataModel/DirectoryCommand.cs +++ b/ShellCommand/DataModel/DirectoryCommand.cs @@ -51,16 +51,20 @@ public bool IsMatch(string workingDir) if (string.IsNullOrEmpty(Match)) return true; - bool reverse = false; - string pattern = Match; - if (Match.StartsWith("!")) + bool result = true; + foreach (var split in Match.Split(new string[] { "<&&>" }, StringSplitOptions.RemoveEmptyEntries)) { - reverse = true; - pattern = Match.Substring(1); + var pattern = split; + bool reverse = false; + if (pattern.StartsWith("!")) + { + reverse = true; + pattern = pattern.Substring(1); + } + var exist = Directory.GetFiles(workingDir, pattern).Any() || Directory.GetDirectories(workingDir, pattern).Any(); + result &= exist ^ reverse; } - - var exist = Directory.GetFiles(workingDir, pattern).Any() || Directory.GetDirectories(workingDir, pattern).Any(); - return exist ^ reverse; + return result; } public ToolStripItem ToMenuItem(string workingDir) diff --git a/ShellCommand/global.template.shellcommand.yaml b/ShellCommand/global.template.shellcommand.yaml index ded4630..b3aaedd 100644 --- a/ShellCommand/global.template.shellcommand.yaml +++ b/ShellCommand/global.template.shellcommand.yaml @@ -14,16 +14,21 @@ GlobalCommands: Match: .gitmodules Icon: "%PROGRAMFILES%/Git/git-cmd.exe" +- Name: Create README.md + Command: cmd /c copy nul README.md + Match: ".git<&&>!README.md" + Icon: "%SystemRoot%/System32/Shell32.dll?70" + - Name: --- - Name: Open Command Window Here(&C) Command: cmd - Icon: C:/WIndows/System32/cmd.exe + Icon: "%SystemRoot%/System32/cmd.exe" - Name: Open Command Window Here (Administrator)(&A) Command: cmd /K "cd /d ""%DIR%""" RunAsAdmin: true - Icon: C:/WIndows/System32/cmd.exe + Icon: "%SystemRoot%/System32/cmd.exe" - Name: ---