+! Copyright (C) 2021 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors ascii assocs combinators grouping io kernel
-math sequences sorting splitting ;
+USING: accessors ascii assocs combinators formatting grouping io
+kernel math sequences sorting splitting ;
 
 IN: command-loop
 

    "List available commands with 'help' or detailed help with 'help cmd'"
    { "?" } <command> ;

PRIVATE>

: new-command-loop ( intro prompt class -- command-loop )


: do-help ( args command-loop -- )
    over empty? [
        nl
        "Commands available:" print
        "===================" print
        nip commands>> [ name>> ] map natural-sort
        [ 6 <groups> ] [ longest length 4 + ] bi
        '[ [ _ CHAR: \s pad-tail write ] each nl ] each nl
    ] [
        dupd find-command [
            nip help>> print
