Skip to content

Commit

Permalink
enabled calling commands from shell w/o entering cli
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonstreete committed Dec 13, 2017
1 parent 07cdb94 commit 70b3600
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
44 changes: 28 additions & 16 deletions cfs_manager/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,30 +246,42 @@ def find_text(s):
else:
return s

def main():
def loop():
"""The main operational loop of the CLI"""
fs = Main_FS()
print()
while True:
cmd = input('(CFS_Manager) >>> ')

if (cmd == '--quit') or (cmd == '-q'):
break
elif cmd == '--commands':
list_commands_summary(fs)
elif (cmd == '--commands --verbose') or (cmd == '--commands -v'):
list_commands_long(fs)
elif 'xyzzy' in cmd.lower():
print("Nothing happens")

else:
cmd = find_text(cmd)
if type(cmd) is list:
cmd = cmd[0].split()+[cmd[1]]+cmd[2].split()
else:
cmd = cmd.split()
evaluator(fs, cmd)
main(fs, cmd)
print("Thank you for using CFS_Manager. Goodbye!\n")

def once():
"""For performing a single action from the shell w/o launching the CLI"""
fs = Main_FS()
del sys.argv[0]
cmd = ' '.join(sys.argv)
print()
main(fs, cmd)

def main(fs, cmd):
"""Evaluates a few basic commands; splits up others to be passed to the dedicated evaluator"""
if cmd == '--commands':
list_commands_summary(fs)
elif (cmd == '--commands --verbose') or (cmd == '--commands -v'):
list_commands_long(fs)
elif 'xyzzy' in cmd.lower():
print("Nothing happens")

else:
cmd = find_text(cmd)
if type(cmd) is list:
cmd = cmd[0].split()+[cmd[1]]+cmd[2].split()
else:
cmd = cmd.split()
evaluator(fs, cmd)

if __name__ == "__main__":
main()
once()
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def readme():
return f.read()

setup(name="CFS_Manager",
version='1.2.0',
version='1.2.1a',
description="A virtual filesystem for accessing storage on multiple cloud services.",
long_description=readme(),
classifiers=[
Expand Down Expand Up @@ -33,9 +33,11 @@ def readme():
],
entry_points='''
[console_scripts]
cfs_manager=cfs_manager.cli:main
cfs-manager=cfs_manager.cli:main
cfsm=cfs_manager.cli:main
cfs_manager=cfs_manager.cli:loop
cfs-manager=cfs_manager.cli:loop
cfsm=cfs_manager.cli:loop
cfs-do=cfs_manager.cli:once
cfs-watch=cfs_manager.cfs_watcher:main
cfs-config=cfs_manager.configuration:main
''',
Expand Down

0 comments on commit 70b3600

Please sign in to comment.