Fix -s and add --help and -h
This commit is contained in:
parent
3e620d5f0b
commit
4919a9903a
13
arc.bqn
13
arc.bqn
|
@ -7,11 +7,20 @@
|
|||
|
||||
opts←{
|
||||
a←•args
|
||||
chars ⇐{0=≠𝕩?" λ$⊕⭍#/\-|+<>^v";⊑𝕩}(»(<"--chars")⊸⍷)⊸/a
|
||||
{𝕤
|
||||
•Out "Usage: "∾•name∾" [OPTION]...
|
||||
--help: Display this help message
|
||||
--levels,-l FILE: load levels from FILE
|
||||
--chars STRING: Characters to display for each game object, needs to have length 15
|
||||
--fchars STRING: Characters to represent each game object in the levels file, needs to have length 15"
|
||||
•Exit 0
|
||||
}⍟((⊑"-h"<⊸⍷a)∨⊑"--help"<⊸⍷a) @
|
||||
|
||||
chars⇐{0=≠𝕩?" λ$⊕⭍#/\-|+<>^v";⊑𝕩}(»(<"--chars")⊸⍷)⊸/a
|
||||
fchars⇐{0=≠𝕩?" λ$⊕⭍#/\-|+<>^v";⊑𝕩}(»(<"--fchars")⊸⍷)⊸/a
|
||||
l←{0=≠𝕩?"levels";⊑𝕩}(»(<"--levels")⊸⍷)⊸/a
|
||||
levels⇐{0=≠𝕩?l;⊑𝕩}(»(<"-l")⊸⍷)⊸/a
|
||||
n⇐{0=≠𝕩?1;1⌊⊑𝕩}•BQN¨⎊{𝕊: •Out "Invalid starting level number" ⋄ •Exit 1}(»(<"-s")⊸⍷)⊸/a
|
||||
n⇐{0=≠𝕩?1;1⌈⊑𝕩}•BQN¨⎊{𝕊: •Out "Invalid starting level number" ⋄ •Exit 1}(»(<"-s")⊸⍷)⊸/a
|
||||
}
|
||||
|
||||
g←Game⎊{𝕊: •Out •CurrentError @ ⋄ •Exit 1} opts.n‿opts.levels‿opts.chars‿opts.fchars‿⟨ansi.defaultB,ansi.yellow,ansi.cyan,ansi.red⟩
|
||||
|
|
Loading…
Reference in New Issue