From 2e56aebcb29a12f61dfb640a40ee8523651cee61 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 1 Apr 2015 14:26:22 -0700 Subject: [PATCH] tools.cat: adding "cat" tool. --- extra/tools/cat/authors.txt | 1 + extra/tools/cat/cat.factor | 27 +++++++++++++++++++++++++++ extra/tools/cat/deploy.factor | 16 ++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 extra/tools/cat/authors.txt create mode 100644 extra/tools/cat/cat.factor create mode 100644 extra/tools/cat/deploy.factor diff --git a/extra/tools/cat/authors.txt b/extra/tools/cat/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/extra/tools/cat/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/extra/tools/cat/cat.factor b/extra/tools/cat/cat.factor new file mode 100644 index 0000000000..0d9ac2927a --- /dev/null +++ b/extra/tools/cat/cat.factor @@ -0,0 +1,27 @@ +! Copyright (C) 2010 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: command-line formatting kernel io io.encodings.binary +io.files namespaces sequences strings ; + +IN: tools.cat + +: cat-lines ( -- ) + [ print flush ] each-line ; + +: cat-stream ( -- ) + [ >string write flush ] each-block ; + +: cat-file ( path -- ) + dup exists? [ + binary [ cat-stream ] with-file-reader + ] [ "%s: not found\n" printf flush ] if ; + +: cat-files ( paths -- ) + [ dup "-" = [ drop cat-lines ] [ cat-file ] if ] each ; + +: run-cat ( -- ) + command-line get [ cat-lines ] [ cat-files ] if-empty ; + +MAIN: run-cat + diff --git a/extra/tools/cat/deploy.factor b/extra/tools/cat/deploy.factor new file mode 100644 index 0000000000..800acb33c4 --- /dev/null +++ b/extra/tools/cat/deploy.factor @@ -0,0 +1,16 @@ +USING: tools.deploy.config ; +H{ + { deploy-c-types? f } + { deploy-help? f } + { deploy-name "cat" } + { "stop-after-last-window?" t } + { deploy-unicode? f } + { deploy-console? t } + { deploy-io 3 } + { deploy-reflection 1 } + { deploy-ui? f } + { deploy-word-defs? f } + { deploy-threads? t } + { deploy-math? t } + { deploy-word-props? f } +}