relpipe-tr-validator: specification and examples v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 02 Dec 2018 20:47:38 +0100
branchv_0
changeset 176 46042297e0d6
parent 175 c079bc35b9b8
child 177 a64671d5f997
relpipe-tr-validator: specification and examples
relpipe-data/examples.xml
relpipe-data/implementation.xml
relpipe-data/specification.xml
--- a/relpipe-data/examples.xml	Sun Dec 02 17:12:34 2018 +0100
+++ b/relpipe-data/examples.xml	Sun Dec 02 20:47:38 2018 +0100
@@ -7,9 +7,37 @@
 	<pořadí>40</pořadí>
 
 	<text xmlns="http://www.w3.org/1999/xhtml">
+		
+		
+		<h3>relpipe-tr-validator</h3>
+		
 		<p>
-			The world is relational!
+			Just a passthrough command, so these pipelines should produce the same hash:
+		</p>
+		
+		<m:pre jazyk="bash"><![CDATA[
+relpipe-in-fstab | relpipe-tr-validator | sha512sum
+relpipe-in-fstab | sha512sum]]></m:pre>
+
+		<p>
+			This tool can be used for testing whether a file contains valid relational data:
 		</p>
+		
+		<m:pre jazyk="bash"><![CDATA[
+if relpipe-tr-validator < "some-file.rp" &> /dev/null; then
+	echo "valid relational data";
+else
+	echo "garbage";
+fi]]></m:pre>
+		
+		<p>or as a one-liner:</p>
+		
+		<m:pre jazyk="bash"><![CDATA[relpipe-tr-validator < "some-file.rp" &> /dev/null && echo "ok" || echo "error"]]></m:pre>
+		
+		<p>
+			If an error is found, it is reported on STDERR. So just omit the <code>&amp;</code> in order to see the error message.
+		</p>
+		
 	</text>
 
 </stránka>
--- a/relpipe-data/implementation.xml	Sun Dec 02 17:12:34 2018 +0100
+++ b/relpipe-data/implementation.xml	Sun Dec 02 20:47:38 2018 +0100
@@ -25,6 +25,7 @@
 			relpipe-out-xml.cpp	executable	output	c++	GNU GPLv3+
 			relpipe-tr-grep.cpp	executable	transformation	c++	GNU GPLv3+
 			relpipe-tr-sed.cpp	executable	transformation	c++	GNU GPLv3+
+			relpipe-tr-validator.cpp	executable	transformation	c++	GNU GPLv3+
 		</m:tabulka>
 		<!--
 			relpipe-web	website	-	XWG XML	GNU FDLv1.3+
--- a/relpipe-data/specification.xml	Sun Dec 02 17:12:34 2018 +0100
+++ b/relpipe-data/specification.xml	Sun Dec 02 20:47:38 2018 +0100
@@ -129,6 +129,15 @@
 			This OpenDocument output can be opened in tools like LibreOffice and further processed (add charts, calculations etc.).
 		</p>
 		
+		<h3>relpipe-tr-validator</h3>
+		
+		<p>
+			A tool that behaves like <code>cat</code>, <code>dd</code> or <code>pv</code> commands i.e. reads data from STDIN and outputs the same data on STDOUT.
+			But compared to these tools, data are parsed and then converted back to the <m:name/> format.
+			Thus if the input was not in this format, the process fails (exit code != 0).
+			Errors (if any) are reported on STDERR.
+		</p>
+		
 	</text>
 
 </stránka>