From 54595382ff1a78f36b94cf06208881a2461e26e5 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 1 Apr 2015 14:31:02 -0700 Subject: [PATCH] tools.move: adding "move" tool. --- extra/tools/move/authors.txt | 1 + extra/tools/move/deploy.factor | 15 +++++++++++++++ extra/tools/move/move.factor | 29 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 extra/tools/move/authors.txt create mode 100644 extra/tools/move/deploy.factor create mode 100644 extra/tools/move/move.factor diff --git a/extra/tools/move/authors.txt b/extra/tools/move/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/extra/tools/move/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/extra/tools/move/deploy.factor b/extra/tools/move/deploy.factor new file mode 100644 index 0000000000..50c33e1023 --- /dev/null +++ b/extra/tools/move/deploy.factor @@ -0,0 +1,15 @@ +USING: tools.deploy.config ; +H{ + { deploy-name "move" } + { deploy-ui? f } + { deploy-c-types? f } + { deploy-console? t } + { deploy-unicode? f } + { "stop-after-last-window?" t } + { deploy-io 3 } + { deploy-reflection 6 } + { deploy-word-props? f } + { deploy-math? t } + { deploy-threads? t } + { deploy-word-defs? f } +} diff --git a/extra/tools/move/move.factor b/extra/tools/move/move.factor new file mode 100644 index 0000000000..d981da17de --- /dev/null +++ b/extra/tools/move/move.factor @@ -0,0 +1,29 @@ +! Copyright (C) 2011 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: combinators command-line io io.directories io.files.info +kernel math namespaces sequences ; + +IN: tools.move + +! FIXME: better error messages when files don't exist + +: usage ( -- ) + "Usage: move source ... target" print ; + +: move-to-dir ( args -- ) + dup last file-info directory? + [ unclip-last move-files-into ] [ drop usage ] if ; + +: move-to-file ( args -- ) + dup last file-info directory? + [ move-to-dir ] [ first2 move-file ] if ; + +: run-move ( -- ) + command-line get dup length { + { [ dup 2 > ] [ drop move-to-dir ] } + { [ dup 2 = ] [ drop move-to-file ] } + [ 2drop usage ] + } cond ; + +MAIN: run-move -- 2.34.1