]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.move: adding "move" tool.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Apr 2015 21:31:02 +0000 (14:31 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Apr 2015 21:31:02 +0000 (14:31 -0700)
extra/tools/move/authors.txt [new file with mode: 0644]
extra/tools/move/deploy.factor [new file with mode: 0644]
extra/tools/move/move.factor [new file with mode: 0644]

diff --git a/extra/tools/move/authors.txt b/extra/tools/move/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/tools/move/deploy.factor b/extra/tools/move/deploy.factor
new file mode 100644 (file)
index 0000000..50c33e1
--- /dev/null
@@ -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 (file)
index 0000000..d981da1
--- /dev/null
@@ -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