Browse Source

write proper help message

pull/1/head
Wesley Kerfoot 4 years ago
parent
commit
4c631bba29
  1. 7
      src/twit2blog.nim
  2. 18
      src/twit2blogpkg/help.nim

7
src/twit2blog.nim

@ -1,4 +1,4 @@
import twit2blogpkg/twitter
import twit2blogpkg/twitter, twit2blogpkg/help
import os, system, parseopt, strutils, tables
when isMainModule:
@ -12,6 +12,8 @@ when isMainModule:
case args.kind
of cmdEnd: break
of cmdShortOption, cmdLongOption:
if (args.key == "help") or (args.key == "h"):
writeHelp()
if args.val == "":
continue
else:
@ -27,7 +29,6 @@ when isMainModule:
twitterParams["thread"] = twitterParams["t"]
if not (twitterParams.hasKey("user") and twitterParams.hasKey("thread")):
stderr.writeLine("Invalid Arguments. Must provide both --user and --thread (or -u and -t). E.g. -u:foo -t:123")
quit(1)
writeHelp()
echo twitterParams["thread"].renderThread(twitterParams["user"])

18
src/twit2blogpkg/help.nim

@ -0,0 +1,18 @@
import system
const
help = """
Usage: twit2blog [opts]
Options:
-u, --user The screen name of the twitter user. E.g. If your twitter is https://twitter.com/foobar, then `foobar`.
-t, --thread The ID of the last tweet in your thread. E.g. 12345.
For more information read the Github readme:
https://github.com/weskerfoot/Twit2Blog#readme
"""
proc writeHelp*(quit=true) =
echo(help)
if quit:
quit(1)
Loading…
Cancel
Save