Skip to content
Snippets Groups Projects
Commit e289669e authored by Aurélien Dunand's avatar Aurélien Dunand Committed by Seblu
Browse files

Add search command


seblu: fix some code

Signed-off-by: default avatarSeblu <sebastien.luttringer@smartjog.com>
parent 8b052d98
No related branches found
No related tags found
No related merge requests found
......@@ -221,7 +221,10 @@ def c_search(parser, args):
'''
Search in repository
'''
raise NotImplementedError("Not yet implemented")
repoman = load_repositories(args)
for repo in repoman:
arrow(repo.config.name)
repo.search(args.pattern)
def c_get(parser, args):
'''
......@@ -351,6 +354,7 @@ p_cat.set_defaults(func=c_cat)
# search command parser
p_search = subparsers.add_parser("search", help=c_search.__doc__.lower())
p_search.add_argument("pattern", help="search pattern in repository")
p_search.set_defaults(func=c_search)
# get command parser
......
......@@ -202,6 +202,22 @@ class Repository(object):
out(' #yellow#MD5:#reset# %s' % payload_md5)
out()
def search(self, pattern):
'''
Search pattern in a repository
'''
images = self.db.ask("SELECT name, version, author, description\
FROM image\
WHERE name LIKE ? OR\
description LIKE ? OR\
author LIKE ?",
tuple( ["%%%s%%" % pattern ] * 3)
).fetchall()
for name, version, author, description in images:
arrow("%s v%s" % (name, version), 1)
out(" #yellow#Author:#reset# %s" % author)
out(" #yellow#Description:#reset# %s" % description)
def _remove_file(self, filename):
'''
Remove a filename from pool. Check if it's not needed by db before
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment