Skip to content

Commit 2acdca0

Browse files
committed
command-line.parser: don't depend on sequences.extras
1 parent 295d409 commit 2acdca0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

basis/command-line/parser/parser.factor

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ USING: accessors arrays assocs classes combinators
55
combinators.short-circuit command-line continuations debugger
66
formatting generic.math io io.pathnames io.sockets kernel lexer
77
math math.parser namespaces parser prettyprint quotations random
8-
sequences sequences.extras splitting strings
9-
strings.tables.private tools.completion unicode vocabs.parser ;
8+
sequences splitting strings strings.tables.private
9+
tools.completion unicode vocabs.parser ;
1010

1111
IN: command-line.parser
1212

@@ -155,7 +155,10 @@ M: class argvalid? instance? ;
155155
[ f swap [ option option-convert ] map ]
156156
if-empty ] }
157157
{ "*" [ f swap [ option option-convert ] map ] }
158-
{ "?" [ ?unclip [ option option-convert ] [ option const>> ] if* ] }
158+
{ "?" [
159+
dup empty?
160+
[ option const>> ]
161+
[ unclip option option-convert ] if ] }
159162
[
160163
[
161164
2dup 1 - swap bounds-check? [
@@ -260,20 +263,22 @@ M: usage-error error. options>> print-help ;
260263
swap [ option-value ] [ option-variable set ] bi ;
261264

262265
: (parse-arguments) ( optional positional command-line -- positional' )
263-
[
266+
[ dup empty? ] [
264267
pick empty? [ f ] [
265268
1 over [ "-" head? ] find-from drop
266269
[ cut ] [ f ] if*
267270
] if [
268271
pick empty? [ f ] [ dup first "-" head? ] if [
269272
overd parse-optional
270273
] [
271-
[ ?unclip ] dip over
272-
[ parse-positional ]
273-
[ unrecognized-arguments ] if
274+
over empty? [
275+
unrecognized-arguments
276+
] [
277+
[ unclip ] dip parse-positional
278+
] if
274279
] if
275280
] dip append
276-
] until-empty nip ;
281+
] until drop nip ;
277282

278283
: parse-arguments ( options command-line -- arguments )
279284
[ dup [ optional? ] partition ] dip { "--" } split1

0 commit comments

Comments
 (0)