relpipe-tr-cut has new syntax since v0.18: --relation, --attribute v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 11 May 2021 22:26:48 +0200
branchv_0
changeset 326 ab7f333f1225
parent 325 4560c5623d7d
child 327 66070d82e12b
relpipe-tr-cut has new syntax since v0.18: --relation, --attribute
relpipe-data/examples-apt.xml
relpipe-data/examples-grep-cut-fstab.xml
relpipe-data/examples-in-xmltable-ssm-gui.xml
relpipe-data/examples/ssm-xmltable-1.makefile
relpipe-data/streamlets-preview.xml
--- a/relpipe-data/examples-apt.xml	Tue May 11 21:35:54 2021 +0200
+++ b/relpipe-data/examples-apt.xml	Tue May 11 22:26:48 2021 +0200
@@ -41,7 +41,7 @@
 		<m:pre jazyk="bash"><![CDATA[apt show emacs25* \
 	| sed 's/^ /+/g' \
 	| relpipe-in-recfile \
-	| relpipe-tr-cut '.*' 'Package|Version|Section|Installed-Size|Homepage|Supported' \
+	| relpipe-tr-cut --relation '.*' --attribute 'Package|Version|Section|Installed-Size|Homepage|Supported' \
 	| relpipe-out-tabular]]></m:pre>
 	
 		<p>And print results in a pretty table:</p>
@@ -86,7 +86,7 @@
 		<m:pre jazyk="bash"><![CDATA[apt show emacs25* \
 	| sed 's/^ /+/g' \
 	| relpipe-in-recfile \
-	| relpipe-tr-cut '.*' 'Package|Version|Section|Installed-Size|Homepage|Supported' \
+	| relpipe-tr-cut --relation '.*' --attribute 'Package|Version|Section|Installed-Size|Homepage|Supported' \
 	| relpipe-out-ods \
 	> apt-packages.fods]]></m:pre>
 	
--- a/relpipe-data/examples-grep-cut-fstab.xml	Tue May 11 21:35:54 2021 +0200
+++ b/relpipe-data/examples-grep-cut-fstab.xml	Tue May 11 22:26:48 2021 +0200
@@ -29,7 +29,7 @@
 		
 		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \
 	| relpipe-tr-grep --relation 'fstab' --attribute 'type' --value '^btrfs|xfs$' \
-	| relpipe-tr-cut 'fstab' 'mount_point' \
+	| relpipe-tr-cut --relation 'fstab' --attribute 'mount_point' \
 	| relpipe-out-nullbyte \
 	| while read -r -d '' m; do
 		echo "$m";
@@ -88,7 +88,7 @@
 
 		<p>We can put away the <code>a</code> attribute from the <code>numbers</code> relation:</p>
 		
-		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut 'numbers' 'b|c' | relpipe-out-tabular</m:pre>
+		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut --relation 'numbers' --attribute 'b|c' | relpipe-out-tabular</m:pre>
 		
 		<p>and leave the <code>letters</code> relation unaffected:</p>
 		
@@ -112,7 +112,7 @@
 
 		<p>Or we can remove <code>a</code> from both relations resp. keep there only attributes whose names match <code>'b|c'</code> regex:</p>
 
-		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut '.*' 'b|c' | relpipe-out-tabular</m:pre>
+		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut --relation '.*' --attribute 'b|c' | relpipe-out-tabular</m:pre>
 		
 		<p>Instead of <code>'.*'</code> we could use <code>'numbers|letters'</code> and in this case it will give the same result:</p>
 		
@@ -136,7 +136,9 @@
 
 		<p>All the time, we are reducing the attributes. But we can also multiply them or change their order:</p>
 		
-		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut 'numbers' 'b|a|c' 'b' 'a' 'a' | relpipe-out-tabular</m:pre>
+		<m:pre jazyk="bash">cat both.rp \
+	| relpipe-tr-cut --relation 'numbers' --attribute 'b|a|c' --attribute 'b' --attribute 'a' --attribute 'a' \
+	| relpipe-out-tabular</m:pre>
 		
 		<p>
 			n.b. the order in <code>'b|a|c'</code> does not matter and if such regex matches, it preserves the original order of the attributes;
@@ -162,7 +164,7 @@
 Record count: 2]]></pre>
 
 		<p>
-			The <code>letters</code> relation stays rock steady and <code>relpipe-tr-cut 'numbers'</code> does not affect it in any way.
+			The <code>letters</code> relation stays rock steady and <code>relpipe-tr-cut --relation 'numbers'</code> does not affect it in any way.
 		</p>
 		
 		<h2>Process CSV files</h2>
@@ -195,7 +197,7 @@
 		<m:pre jazyk="bash"><![CDATA[cat tasks.csv \
 	| relpipe-in-csv \
 	| relpipe-tr-grep --relation 'csv' --attribute 'type' --value 'FIXME' \
-	| relpipe-tr-cut 'csv' 'file|description' \
+	| relpipe-tr-cut  --relation 'csv' --attribute 'file|description' \
 	| relpipe-out-tabular]]></m:pre>
 	
 		<p>and get result like this:</p>
--- a/relpipe-data/examples-in-xmltable-ssm-gui.xml	Tue May 11 21:35:54 2021 +0200
+++ b/relpipe-data/examples-in-xmltable-ssm-gui.xml	Tue May 11 22:26:48 2021 +0200
@@ -39,8 +39,8 @@
 			Thanks to regular expressions, it is very concise. But of course, we can make it more explicit:
 		</p>
 		
-		<m:pre jazyk="bash"><![CDATA[relpipe-tr-cut "chapter" "(name|requirements|recommendations|informations)"
-# relation name ^          ^ attribute names to be passed through (others are filtered out)]]></m:pre>
+		<m:pre jazyk="bash"><![CDATA[relpipe-tr-cut --relation "chapter" --attribute "(name|requirements|recommendations|informations)"
+#            relation name ^                     ^ attribute names to be passed through (others are filtered out)]]></m:pre>
 		
 		<p>We also set the window title (using the <code>-title</code> Qt option) and get the chart:</p>
 		
--- a/relpipe-data/examples/ssm-xmltable-1.makefile	Tue May 11 21:35:54 2021 +0200
+++ b/relpipe-data/examples/ssm-xmltable-1.makefile	Tue May 11 22:26:48 2021 +0200
@@ -17,4 +17,4 @@
 	cat build/statistics.rp | relpipe-out-tabular
 	
 statistics-chart: build/statistics.rp
-	cat build/statistics.rp | relpipe-tr-cut ".*" "(name|.*s)" | relpipe-out-gui -title "Sane software manifesto – chart of rule types"
+	cat build/statistics.rp | relpipe-tr-cut --relation ".*" --attribute "(name|.*s)" | relpipe-out-gui -title "Sane software manifesto – chart of rule types"
--- a/relpipe-data/streamlets-preview.xml	Tue May 11 21:35:54 2021 +0200
+++ b/relpipe-data/streamlets-preview.xml	Tue May 11 22:26:48 2021 +0200
@@ -45,9 +45,9 @@
 			--as 'ocr_text' \
 		--streamlet pdftotext --as 'pdf_text' \
 	| relpipe-tr-awk \
-		--relation filesystem \
+		--relation 'filesystem' \
 		--where 'path ~ /\.sh$/ || url ~ /alt2xml\.globalcode\.info/ || ocr_text ~ /GNU/ || pdf_text ~ /Sane/' \
-	| relpipe-tr-cut filesystem 'path|url|width|height|page_count|lines_count' \
+	| relpipe-tr-cut --relation 'filesystem' --attribute 'path|url|width|height|page_count|lines_count' \
 	| relpipe-out-tabular
 
 # if too wide, add: | less -RSi]]></m:pre>