]> gitweb.factorcode.org Git - factor.git/blob - extra/tools/cat/cat.factor
stomp: unescape-header and adjust-stomp-version
[factor.git] / extra / tools / cat / cat.factor
1 ! Copyright (C) 2010 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
3
4 USING: command-line io io.encodings io.encodings.binary io.files
5 kernel namespaces sequences ;
6
7 IN: tools.cat
8
9 : cat-stream ( -- )
10     input-stream get binary re-decode
11     output-stream get binary re-encode
12     '[ _ [ stream-write ] [ stream-flush ] bi ] each-stream-block ;
13
14 : cat-file ( path -- )
15     [ binary [ cat-stream ] with-file-reader ]
16     [ write ": not found" print flush ] if-file-exists ;
17
18 : cat-files ( paths -- )
19     [ dup "-" = [ drop cat-stream ] [ cat-file ] if flush ] each ;
20
21 : run-cat ( -- )
22     command-line get [ cat-stream ] [ cat-files ] if-empty ;
23
24 MAIN: run-cat