]> gitweb.factorcode.org Git - factor.git/commitdiff
command-line.loop: moving to extra/command-loop for now.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 14 Mar 2021 15:18:11 +0000 (08:18 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 14 Mar 2021 15:18:11 +0000 (08:18 -0700)
basis/command-line/loop/authors.txt [deleted file]
basis/command-line/loop/loop.factor [deleted file]
basis/command-line/loop/summary.txt [deleted file]
extra/command-loop/authors.txt [new file with mode: 0644]
extra/command-loop/command-loop.factor [new file with mode: 0644]
extra/command-loop/summary.txt [new file with mode: 0644]
extra/gemini/cli/cli.factor

diff --git a/basis/command-line/loop/authors.txt b/basis/command-line/loop/authors.txt
deleted file mode 100644 (file)
index e091bb8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-John Benediktsson
diff --git a/basis/command-line/loop/loop.factor b/basis/command-line/loop/loop.factor
deleted file mode 100644 (file)
index 9c6a2dd..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-
-USING: accessors ascii assocs combinators grouping io kernel
-math sequences sorting splitting ;
-
-IN: command-line.loop
-
-TUPLE: command name quot help abbrevs ;
-
-C: <command> command
-
-TUPLE: command-loop intro prompt commands abbrevs ;
-
-GENERIC: add-command ( command command-loop -- )
-GENERIC: find-command ( name command-loop -- command )
-GENERIC: handle-command ( args command-loop -- )
-GENERIC: missing-command ( args name command-loop -- )
-GENERIC: run-command-loop ( command-loop -- )
-
-<PRIVATE
-
-: do-help ( args command-loop -- )
-    over empty? [
-        "Available commands:" print
-        "-------------------" print
-        nip commands>> [ name>> ] map natural-sort
-        [ 6 <groups> ] [ longest length 4 + ] bi
-        '[ [ _ CHAR: \s pad-tail write ] each nl ] each
-    ] [
-        dupd find-command [
-            nip help>> print
-        ] [
-            "ERROR: Command '" "' not found" surround print
-        ] if*
-    ] if ;
-
-: <help-command> ( command-loop -- command )
-    "help" swap '[ _ do-help ]
-    "List available commands with 'help' or detailed help with 'help cmd'"
-    { "?" } <command> ;
-
-PRIVATE>
-
-: new-command-loop ( intro prompt class -- command-loop )
-    new
-        swap >>prompt
-        swap >>intro
-        V{ } clone >>commands
-        V{ } clone >>abbrevs
-    [ <help-command> ] [ add-command ] [ ] tri ;
-
-: <command-loop> ( intro prompt -- command-loop )
-    command-loop new-command-loop ;
-
-M: command-loop add-command ( command command-loop -- )
-    {
-        [ commands>> push ]
-        [ [ [ name>> ] keep ] dip [ abbrevs>> ] bi@ '[ _ set-at ] with each ]
-    } 2cleave ;
-
-M: command-loop find-command ( name command-loop -- command )
-    [ abbrevs>> ?at drop ]
-    [ commands>> [ name>> = ] with find nip ] bi ;
-
-M: command-loop handle-command
-    swap " " split1 swap >lower
-    [ pick find-command ] keep swap [
-        nip quot>> call( args -- ) drop
-    ] [
-        rot missing-command
-    ] if* flush ;
-
-M: command-loop missing-command ( args name command-loop -- )
-    drop "ERROR: Unknown command '" "'" surround print drop ;
-
-M: command-loop run-command-loop
-    dup intro>> [ print ] when* [
-        dup prompt>> [ write bl flush ] when* readln
-        [ [ over handle-command ] unless-empty t ] [ f ] if*
-    ] loop drop ;
-
-: command-loop-main ( -- )
-    "This is a test!" "TEST>" <command-loop> run-command-loop ;
-
-MAIN: command-loop-main
diff --git a/basis/command-line/loop/summary.txt b/basis/command-line/loop/summary.txt
deleted file mode 100644 (file)
index c46272d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Generic line-oriented command interpreter.
diff --git a/extra/command-loop/authors.txt b/extra/command-loop/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/command-loop/command-loop.factor b/extra/command-loop/command-loop.factor
new file mode 100644 (file)
index 0000000..1187779
--- /dev/null
@@ -0,0 +1,84 @@
+
+USING: accessors ascii assocs combinators grouping io kernel
+math sequences sorting splitting ;
+
+IN: command-loop
+
+TUPLE: command name quot help abbrevs ;
+
+C: <command> command
+
+TUPLE: command-loop intro prompt commands abbrevs ;
+
+GENERIC: add-command ( command command-loop -- )
+GENERIC: find-command ( name command-loop -- command )
+GENERIC: handle-command ( args command-loop -- )
+GENERIC: missing-command ( args name command-loop -- )
+GENERIC: run-command-loop ( command-loop -- )
+
+<PRIVATE
+
+: do-help ( args command-loop -- )
+    over empty? [
+        "Available commands:" print
+        "-------------------" print
+        nip commands>> [ name>> ] map natural-sort
+        [ 6 <groups> ] [ longest length 4 + ] bi
+        '[ [ _ CHAR: \s pad-tail write ] each nl ] each
+    ] [
+        dupd find-command [
+            nip help>> print
+        ] [
+            "ERROR: Command '" "' not found" surround print
+        ] if*
+    ] if ;
+
+: <help-command> ( command-loop -- command )
+    "help" swap '[ _ do-help ]
+    "List available commands with 'help' or detailed help with 'help cmd'"
+    { "?" } <command> ;
+
+PRIVATE>
+
+: new-command-loop ( intro prompt class -- command-loop )
+    new
+        swap >>prompt
+        swap >>intro
+        V{ } clone >>commands
+        V{ } clone >>abbrevs
+    [ <help-command> ] [ add-command ] [ ] tri ;
+
+: <command-loop> ( intro prompt -- command-loop )
+    command-loop new-command-loop ;
+
+M: command-loop add-command ( command command-loop -- )
+    {
+        [ commands>> push ]
+        [ [ [ name>> ] keep ] dip [ abbrevs>> ] bi@ '[ _ set-at ] with each ]
+    } 2cleave ;
+
+M: command-loop find-command ( name command-loop -- command )
+    [ abbrevs>> ?at drop ]
+    [ commands>> [ name>> = ] with find nip ] bi ;
+
+M: command-loop handle-command
+    swap " " split1 swap >lower
+    [ pick find-command ] keep swap [
+        nip quot>> call( args -- ) drop
+    ] [
+        rot missing-command
+    ] if* flush ;
+
+M: command-loop missing-command ( args name command-loop -- )
+    drop "ERROR: Unknown command '" "'" surround print drop ;
+
+M: command-loop run-command-loop
+    dup intro>> [ print ] when* [
+        dup prompt>> [ write bl flush ] when* readln
+        [ [ over handle-command ] unless-empty t ] [ f ] if*
+    ] loop drop ;
+
+: command-loop-main ( -- )
+    "This is a test!" "TEST>" <command-loop> run-command-loop ;
+
+MAIN: command-loop-main
diff --git a/extra/command-loop/summary.txt b/extra/command-loop/summary.txt
new file mode 100644 (file)
index 0000000..c46272d
--- /dev/null
@@ -0,0 +1 @@
+Generic line-oriented command interpreter.
index d54f28ebd04758073e069a6c9f83541a943b24d8..58582257b0b362ad55a2085333586977aabbc584 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2021 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors arrays combinators.short-circuit
-command-line.loop formatting gemini gemini.private io
-io.directories io.encodings.string io.encodings.utf8 io.files
-io.files.temp io.launcher kernel math math.parser namespaces
-present sequences splitting system urls webbrowser ;
+USING: accessors arrays combinators.short-circuit command-loop
+formatting gemini gemini.private io io.directories
+io.encodings.string io.encodings.utf8 io.files io.files.temp
+io.launcher kernel math math.parser namespaces present sequences
+splitting system urls webbrowser ;
 
 IN: gemini.cli