-
Notifications
You must be signed in to change notification settings - Fork 5
Move towards API #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move towards API #79
Conversation
jamesaoverton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what I was asking for. Thanks!
One important change: library functions (i.e. functions designed to be called from other code) should not call sys.exit, they should raise exceptions. I only saw one of these in the diff, but there could be more.
It's also better not to print from library functions. You moved a bunch of prints to the run functions, which is the better approach. I still see a few prints in the library functions. If it's easy to get rid of them, that would be best.
I would have put all the run functions in cli.py, but I guess it doesn't make a big difference.
jamesaoverton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good, but I'd like one more change: I'd like to be able to get at all the main commands with a single import cogs then cogs.add. I think the best way to do that is in cogs/__init__.py with from cogs.add import add for each main command.
I think this change will cause some problems with the imports cogs/cli.py, mainly with the msg() calls. Maybe they could be moved into cogs/cli.py.
jamesaoverton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Resolves #78
This is a first pass. I made sure that all the "operations" accepted actual arguments, rather than the command line
args. I also added some errors that a command line user would probably never see, but somebody using the API may see.@jamesaoverton - would you like even more separation between the CLI and the API?