OSDN Git Service

Add PrettifyYAML and QueryYAML plugins
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Thu, 8 Jul 2021 13:30:13 +0000 (22:30 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Thu, 8 Jul 2021 13:30:13 +0000 (22:30 +0900)
Plugins/Commands/yq/yq.bat [new file with mode: 0644]
Plugins/Plugins.xml

diff --git a/Plugins/Commands/yq/yq.bat b/Plugins/Commands/yq/yq.bat
new file mode 100644 (file)
index 0000000..289c064
--- /dev/null
@@ -0,0 +1,22 @@
+@echo off
+
+set DOWNLOAD_URL=https://github.com/mikefarah/yq/releases/download/v4.9.7/yq_windows_386.exe
+set YQ_PATH=Commands\yq\yq_windows_386.exe
+set MESSAGE='yq command is not installed. Do you want to download it from %DOWNLOAD_URL%?'
+set TITLE='YAML Data Querier Plugin'
+
+cd "%APPDATA%\WinMerge"
+if not exist %YQ_PATH% (
+  cd "%~dp0..\.."
+  if not exist %YQ_PATH% (
+    cd "%APPDATA%\WinMerge"
+    for %%i in (%YQ_PATH%) do mkdir %%~pi 2> NUL
+    powershell "if ((New-Object -com WScript.Shell).Popup(%MESSAGE%,0,%TITLE%,1) -ne 1) { throw }" > NUL
+    if errorlevel 1 (
+      echo "download is canceled" 1>&2
+    ) else (
+      start "Downloading..." /WAIT powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest %DOWNLOAD_URL% -Outfile %YQ_PATH%"
+    )
+  )
+)
+%YQ_PATH% %*
index 8a3796e..2eef54c 100644 (file)
     <command>cmd /c type "${SRC_FILE}" | "${WINMERGE_HOME}\Commands\jq\jq.exe" ${*} &gt; "${DST_FILE}"</command>
     </unpack-file>
   </plugin>
+  <plugin name="PrettifyYAML">
+    <event value="FILE_PACK_UNPACK" />
+    <description value="YAML Prettier with yq command. &#xD;&#xA;Arguments: Filter or command line options passed to the yq command." />
+    <file-filters value="\.yaml$;\.yml$" />
+    <is-automatic value="false" />
+    <unpacked-file-extension value=".yaml" />
+    <extended-properties value="ProcessType=Prettification;MenuCaption=Prettify YAML;GenerateEditorScript" />
+    <arguments value="-P e" />
+    <unpack-file>
+    <command>cmd /c type "${SRC_FILE}" | "${WINMERGE_HOME}\Commands\yq\yq.bat" ${*} &gt; "${DST_FILE}"</command>
+    </unpack-file>
+  </plugin>
   <plugin name="QueryCSV">
     <event value="FILE_PACK_UNPACK" />
     <description value="CSV Querier with q command. &#xD;&#xA;Arguments: SQL statement or command line options passed to the q command." />
       <command>cmd /c type "${SRC_FILE}" | "${WINMERGE_HOME}\Commands\jq\jq.exe" ${*} &gt; "${DST_FILE}"</command>
     </unpack-file>
   </plugin>
+  <plugin name="QueryYAML">
+    <event value="FILE_PACK_UNPACK" />
+    <description value="YAML Querier with yq command. &#xD;&#xA;Arguments: Filter or command line options passed to the yq command." />
+    <file-filters value="\.yaml$;\.yml$" />
+    <is-automatic value="false" />
+    <unpacked-file-extension value=".yaml" />
+    <extended-properties value="ProcessType=Data Query;MenuCaption=Query YAML Data...;ArgumentsRequired" />
+    <arguments value="e &quot;.&quot; -" />
+    <unpack-file>
+      <command>cmd /c type "${SRC_FILE}" | "${WINMERGE_HOME}\Commands\yq\yq.bat" ${*} &gt; "${DST_FILE}"</command>
+    </unpack-file>
+  </plugin>
   <plugin name="VisualizeGraphviz">
     <event value="FILE_PACK_UNPACK" />
     <description value="Graphviz Visualizer. &#xD;&#xA;Arguments: Command line options passed to the dot command." />