 ! Copyright (C) 2016 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: alien.data command-line formatting io io.encodings
+USING: alien.data command-line io io.encodings
 io.encodings.binary io.files kernel math math.bitwise
-math.vectors math.vectors.simd namespaces sequences
+math.parser math.vectors math.vectors.simd namespaces sequences
 specialized-arrays ;
 
 SPECIALIZED-ARRAY: uchar-16

    input-stream get binary re-decode
    [ count-lines ] with-input-stream* ;

PRIVATE>

: wc ( path -- n )


: run-wc ( -- )
    command-line get [
        wc-stdin f print-wc
    ] [
        [
            dup file-exists? [
                [ wc ] keep dupd print-wc
            ] [
                write ": not found" print flush f
            ] if
        ] map sift dup length 1 > [ sum "total" print-wc ] [ drop ] if
    ] if-empty ;

MAIN: run-wc
