Skip to content

Commit

Permalink
Merge pull request #105 from diggyk/master
Browse files Browse the repository at this point in the history
Added ability to list quests by query
  • Loading branch information
mcot2 committed Dec 8, 2015
2 parents b0d95a4 + 2283f61 commit ac39f31
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions bin/hermes
Original file line number Diff line number Diff line change
Expand Up @@ -647,16 +647,21 @@ def create_event(args):
def list_quests(args):
logging.debug("list_quests()")

response = request_get(
"/api/v1/quests?filterClosed=true&limit=all&progressInfo=true"
)
url = "/api/v1/quests?filterClosed=true&limit=all&progressInfo=true"

if args.user:
url += "&byCreator={}".format(args.user)
if args.hosts:
url += "&hostnames={}".format(urllib.quote_plus(args.hosts))
if args.query:
url += "&hostQuery={}".format(urllib.quote_plus(args.query))

response = request_get(url)
quests = response.json()["quests"]

print "OPEN QUESTS:"
print "\t* Labors: unstarted/in-progress/completed/total\n\n"
for quest in quests:
if args.user and quest["creator"] != args.user:
continue
embark_time = parser.parse(quest["embarkTime"])
embark_time = embark_time.replace(tzinfo=tz.tzutc())
embark_time = embark_time.astimezone(tz.tzlocal())
Expand Down Expand Up @@ -1070,6 +1075,14 @@ def parse_cli_args():
"--user",
help="Filter the list of Quests to those created by the given user"
)
quest_list_parser.add_argument(
"--hosts", type=str,
help="Filter Quests to those relating to Hosts, separated by comma"
)
quest_list_parser.add_argument(
"--query", type=str,
help="Filter Quests to those relating to Hosts return by query"
)
quest_list_parser.set_defaults(func=list_quests)

# quest show parser
Expand Down
2 changes: 1 addition & 1 deletion hermes/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.2"
__version__ = "0.6.9"

0 comments on commit ac39f31

Please sign in to comment.