wmtools/src/parser.nim

46 lines
1.3 KiB
Nim
Raw Normal View History

2023-11-22 21:19:37 +00:00
import os
import argparse
import common
proc parseArgs*() =
let params = commandLineParams()
var p = newParser:
help("WMTools : a set of tools to output option to your program of choice i.e. Rofi")
2023-11-22 21:42:13 +00:00
arg("input",help="the tool to run, i.e. furrytime, pingclock, volurrme, etc.")
2023-11-23 09:27:54 +00:00
arg("adjust", help="(up, down, mute) allows to send extra commands. i.e. when run with volurrme, allows to adjust the volume",default=some("None"))
2023-11-22 21:19:37 +00:00
try:
var opts = p.parse(params)
case opts.input
of "furrytime", "fuzzytime", "time":
myConfig.run = FurryTime
of "pingclock", "pingclurrk", "ping":
myConfig.run = PingClock
2023-11-22 21:42:13 +00:00
of "batturry", "battery", "bat":
myConfig.run = Batturry
2023-11-22 22:02:52 +00:00
of "volurrme", "volume", "vol":
myConfig.run = Volurrme
2023-11-23 09:27:54 +00:00
of "netwurrk", "network", "net":
myConfig.run = Netwurrk
2023-11-23 09:41:16 +00:00
of "emurrji", "emoji":
myConfig.run = Emurrji
2023-11-22 21:19:37 +00:00
else:
echo p.help
quit(1)
2023-11-22 22:02:52 +00:00
case opts.adjust
of "volup":
myConfig.extra_args.add(VolUp)
of "voldown":
myConfig.extra_args.add(VolDown)
of "mute","volmute":
myConfig.extra_args.add(VolMute)
2023-11-22 21:19:37 +00:00
except ShortCircuit as err:
if err.flag == "argparse_help":
echo err.help
quit(1)
except UsageError:
stderr.writeLine getCurrentExceptionMsg()
quit(1)