]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.hexdump: support stdin hexdump.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Mar 2018 20:53:47 +0000 (13:53 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Mar 2018 20:53:47 +0000 (13:53 -0700)
basis/tools/hexdump/hexdump.factor

index 2d94b71a265a24cc446fe1d16292fb33fed93fe9..2011260ce477de9ca1fbf52613199ce3cd57d5f9 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays ascii byte-arrays byte-vectors command-line
-grouping io io.encodings.binary io.files io.streams.string
-kernel math math.parser namespaces sequences splitting strings ;
+USING: accessors ascii byte-arrays byte-vectors command-line
+grouping io io.encodings io.encodings.binary io.files
+io.streams.string kernel math math.parser namespaces sequences ;
 IN: tools.hexdump
 
 <PRIVATE
@@ -47,6 +47,11 @@ M: byte-vector hexdump. hexdump-bytes ;
     binary file-contents hexdump. ;
 
 : hexdump-main ( -- )
-    command-line get [ hexdump-file ] each ;
+    command-line get [
+        input-stream get dup decoder? [ stream>> ] when
+        stream-contents* hexdump.
+    ] [
+        [ hexdump-file ] each
+    ] if-empty ;
 
 MAIN: hexdump-main