adding ability to specify path for command tree

pull/6/head
deadc0de6 6 years ago
parent 4417dd2abb
commit fdc59f9ad5

@ -39,8 +39,9 @@ Usage:
{1} ls [--catalog=<path>] [-rV] [<path>]
{1} find [--catalog=<path>] [-sV] <term>
{1} rm [--catalog=<path>] [-fV] <storage>
{1} tree [--catalog=<path>] [-V]
{1} tree [--catalog=<path>] [-V] [<path>]
{1} graph [--catalog=<path>] [-V] [<path>]
{1} help
{1} --help
{1} --version
@ -113,7 +114,12 @@ def cmd_find(args, noder, top):
def cmd_tree(args, noder, top):
noder.print_tree(top)
path = args['<path>']
node = top
if path:
node = noder.get_node(top, path)
if node:
noder.print_tree(node)
def cmd_graph(args, noder, top):
@ -132,6 +138,10 @@ def banner():
def main():
args = docopt(USAGE, version=VERSION)
if args['help']:
print(USAGE)
return True
# print banner
banner()

@ -42,6 +42,15 @@ class Noder:
''' return a list of all storage names '''
return [x.name for x in list(top.children)]
def get_node(self, top, path):
''' get the node at path '''
r = anytree.resolver.Resolver('name')
try:
return r.get(top, path)
except anytree.resolver.ChildResolverError:
Logger.err('No node at path \"{}\"'.format(path))
return None
###############################################################
# node creationg
###############################################################

Loading…
Cancel
Save