metar: add a main.

master
John Benediktsson 2020-05-20 19:47:47 -07:00
parent 918436af7e
commit 15b0f07b37
1 changed files with 12 additions and 4 deletions

View File

@ -2,10 +2,10 @@
! See http://factorcode.org/license.txt for BSD license ! See http://factorcode.org/license.txt for BSD license
USING: accessors arrays ascii assocs calendar calendar.format USING: accessors arrays ascii assocs calendar calendar.format
combinators continuations csv formatting fry grouping combinators command-line continuations csv formatting fry
http.client io io.encodings.ascii io.files io.styles kernel math grouping http.client io io.encodings.ascii io.files io.styles
math.extras math.parser memoize regexp sequences sorting.human kernel math math.extras math.parser memoize namespaces regexp
splitting strings urls wrap.strings ; sequences sorting.human splitting strings urls wrap.strings ;
IN: metar IN: metar
@ -199,6 +199,7 @@ CONSTANT: compass-directions H{
"V" split1 [ parse-compass ] bi@ "V" split1 [ parse-compass ] bi@
", variable from %s to %s" sprintf ; ", variable from %s to %s" sprintf ;
! FIXME: "1 1/2SM" visibility doesn't work
: parse-visibility ( str -- str' ) : parse-visibility ( str -- str' )
dup first { dup first {
{ CHAR: M [ rest "less than " ] } { CHAR: M [ rest "less than " ] }
@ -734,3 +735,10 @@ M: station taf. cccc>> taf. ;
M: string taf. M: string taf.
[ taf <taf-report> taf-report. ] [ taf <taf-report> taf-report. ]
[ drop "%s TAF not found\n" printf ] recover ; [ drop "%s TAF not found\n" printf ] recover ;
: metar-main ( -- )
command-line get [
[ metar print ] [ taf print ] bi nl
] each ;
MAIN: metar-main