~reesmichael1/roman

ref: 3784df6eb213fc0ccd683ed396d42645e1bca718 roman/src/roman.nim -rw-r--r-- 833 bytes
3784df6eMichael Rees Fix crash when displaying very long link in post 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import argparse

import romanpkg / main


proc showVersion() =
  echo "roman 0.1.0"


when isMainModule:
  var p = newParser("roman"):
    help("a command line RSS feed reader")
    flag("-v", "--version", help = "print version information")
    command("subscribe"):
      help("add a feed URL to the subscription list")
      option("-t", "--type",
        help = "explicitly state type of feed (accepted: \"rss\" or \"atom\")")
      arg("url", help = "the URL of the feed to subscribe to")
      run:
        subscribe(opts.url, opts.type)
    command("manage"):
      help("manage subscribed feeds")
      run:
        manage()
    run:
      if opts.version:
        showVersion()
      if opts.argparseCommand == "":
        main()

  try:
    p.run()

  except UsageError:
    let msg = getCurrentExceptionMsg()
    echo msg