@@ -69,27 +69,27 @@ variable [Monad m] [MonadStateOf ArgList m]
6969
7070/-- Process a short option of the form `-x=arg`. -/
7171@[inline] public def shortOptionWithEq (handle : Char → m α) (opt : String) : m α := do
72- consArg (opt.drop 3 ); handle (opt. get ⟨1 ⟩)
72+ consArg (opt.drop 3 ); handle (String.Pos.Raw. get opt ⟨1 ⟩)
7373
7474/-- Process a short option of the form `"-x arg"`. -/
7575@[inline] public def shortOptionWithSpace (handle : Char → m α) (opt : String) : m α := do
76- consArg <| opt.drop 2 |>.trimLeft; handle (opt. get ⟨1 ⟩)
76+ consArg <| opt.drop 2 |>.trimLeft; handle (String.Pos.Raw. get opt ⟨1 ⟩)
7777
7878/-- Process a short option of the form `-xarg`. -/
7979@[inline] public def shortOptionWithArg (handle : Char → m α) (opt : String) : m α := do
80- consArg (opt.drop 2 ); handle (opt. get ⟨1 ⟩)
80+ consArg (opt.drop 2 ); handle (String.Pos.Raw. get opt ⟨1 ⟩)
8181
8282/-- Process a multiple short options grouped together (ex. `-xyz` as `x`, `y`, `z`). -/
8383@[inline] public def multiShortOption (handle : Char → m PUnit) (opt : String) : m PUnit := do
8484 let rec loop (p : String.Pos.Raw) := do
85- if h : opt .atEnd p then
85+ if h : p .atEnd opt then
8686 return
8787 else
88- handle (opt .get' p h)
89- loop (opt .next' p h)
88+ handle (p .get' opt h)
89+ loop (p .next' opt h)
9090 termination_by opt.utf8ByteSize - p.byteIdx
9191 decreasing_by
92- simp [String.atEnd] at h
92+ simp [String.Pos.Raw. atEnd] at h
9393 apply Nat.sub_lt_sub_left h
9494 exact String.Pos.Raw.byteIdx_lt_byteIdx_next opt p
9595 loop ⟨1 ⟩
@@ -100,17 +100,17 @@ variable [Monad m] [MonadStateOf ArgList m]
100100 if pos = opt.endPos then
101101 handle opt
102102 else do
103- consArg <| opt.extract (opt .next pos) opt.endPos
104- handle <| opt. extract 0 pos
103+ consArg <| (pos .next opt).extract opt opt.endPos
104+ handle <| String.Pos.Raw. extract opt 0 pos
105105
106106/-- Splits a long option of the form `--long=arg` into `--long` and `arg`. -/
107107@[inline] public def longOptionOrEq (handle : String → m α) (opt : String) : m α :=
108108 let pos := opt.posOf '='
109109 if pos = opt.endPos then
110110 handle opt
111111 else do
112- consArg <| opt.extract (opt .next pos) opt.endPos
113- handle <| opt. extract 0 pos
112+ consArg <| (pos .next opt).extract opt opt.endPos
113+ handle <| String.Pos.Raw. extract opt 0 pos
114114
115115/-- Process a long option of the form `--long`, `--long=arg`, `"--long arg"`. -/
116116@[inline] public def longOption (handle : String → m α) : String → m α :=
@@ -122,9 +122,9 @@ variable [Monad m] [MonadStateOf ArgList m]
122122 (opt : String)
123123: m α :=
124124 if opt.length == 2 then -- `-x`
125- shortHandle (opt. get ⟨1 ⟩)
125+ shortHandle (String.Pos.Raw. get opt ⟨1 ⟩)
126126 else -- `-c(.+)`
127- match opt. get ⟨2 ⟩ with
127+ match String.Pos.Raw. get opt ⟨2 ⟩ with
128128 | '=' => -- `-x=arg`
129129 shortOptionWithEq shortHandle opt
130130 | ' ' => -- `"-x arg"`
@@ -138,7 +138,7 @@ An option is an argument of length > 1 starting with a dash (`-`).
138138An option may consume additional elements of the argument list.
139139-/
140140@[inline] public def option (handlers : OptionHandlers m α) (opt : String) : m α :=
141- if opt. get ⟨1 ⟩ == '-' then -- `--(.*)`
141+ if String.Pos.Raw. get opt ⟨1 ⟩ == '-' then -- `--(.*)`
142142 longOption handlers.long opt
143143 else
144144 shortOption handlers.short handlers.longShort opt
@@ -148,7 +148,7 @@ public def processLeadingOption (handle : String → m PUnit) : m PUnit := do
148148 match (← getArgs) with
149149 | [] => pure ()
150150 | arg :: args =>
151- if arg.length > 1 && arg. get 0 == '-' then -- `-(.+)`
151+ if arg.length > 1 && String.Pos.Raw. get arg 0 == '-' then -- `-(.+)`
152152 setArgs args
153153 handle arg
154154
@@ -159,7 +159,7 @@ Consumes empty leading arguments in the argument list.
159159public partial def processLeadingOptions (handle : String → m PUnit) : m PUnit := do
160160 if let arg :: args ← getArgs then
161161 let len := arg.length
162- if len > 1 && arg. get 0 == '-' then -- `-(.+)`
162+ if len > 1 && String.Pos.Raw. get arg 0 == '-' then -- `-(.+)`
163163 setArgs args
164164 handle arg
165165 processLeadingOptions handle
@@ -173,7 +173,7 @@ public partial def collectArgs
173173: m (Array String) := do
174174 if let some arg ← takeArg? then
175175 let len := arg.length
176- if len > 1 && arg. get 0 == '-' then -- `-(.+)`
176+ if len > 1 && String.Pos.Raw. get arg 0 == '-' then -- `-(.+)`
177177 option arg
178178 collectArgs option args
179179 else if len == 0 then -- skip empty args
0 commit comments