Skip to content

Conversation

@beckyjackson
Copy link
Collaborator

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?

Copy link
Member

@jamesaoverton jamesaoverton left a 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 jamesaoverton requested review from jamesaoverton and removed request for jamesaoverton October 26, 2020 20:58
Copy link
Member

@jamesaoverton jamesaoverton left a 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.

Copy link
Member

@jamesaoverton jamesaoverton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@beckyjackson beckyjackson merged commit 313651c into master Nov 4, 2020
@beckyjackson beckyjackson deleted the api branch November 4, 2020 15:01
@beckyjackson beckyjackson mentioned this pull request Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Pythonic API

3 participants