core-api / coreapi-cli

An interactive command line client for Core API.
Other
16 stars 5 forks source link

Add REPL functionality #20

Closed decentral1se closed 6 years ago

decentral1se commented 7 years ago

Would you be willing to accept a PR that integrates with https://github.com/click-contrib/click-repl/? I've played around with it and it definitely improves the experience of navigating schemas.

Without anything beyond the following diff,

diff --git a/coreapi_cli/main.py b/coreapi_cli/main.py
index 8537187..1c084a4 100644
--- a/coreapi_cli/main.py
+++ b/coreapi_cli/main.py
@@ -5,6 +5,7 @@ from coreapi_cli.display import display
 from coreapi_cli.debug import DebugSession
 from coreapi_cli.history import History, dump_history, load_history
 import click
+import click_repl
 import coreapi
 import json
 import os
@@ -741,6 +742,7 @@ history.add_command(history_show, name='show')
 client.add_command(codecs)
 codecs.add_command(codecs_show, name='show')

+click_repl.register_repl(client)

 if __name__ == '__main__':
     client()

It's looking nice:

get-complete

opt-complete

I'd try to add some more features there - colors, fuzzy finder, history, etc.

tomchristie commented 6 years ago

That's really neat! I think I'll keep that out of the scope of this project, since I don't want to have to maintain support for it. Perhaps a neat idea for a stand alone tool that only uses the repl?