Skip to content

Commit

Permalink
fix: add query helper to interact and use a standard ipython shell
Browse files Browse the repository at this point in the history
without ipython_start the profile of the user will not be loaded
  • Loading branch information
iloveitaly committed Jan 24, 2024
1 parent ec5008c commit 896be6f
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions netsuite/cli/interact.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

import IPython
import traitlets

Expand All @@ -18,24 +20,28 @@ def add_parser(parser, subparser):
def interact(config, args):
ns = NetSuite(config)

user_ns = {"ns": ns}
user_ns = {
"ns": ns,
"query": lambda **kwargs: asyncio.run(ns.rest_api.suiteql(**kwargs)),
}

banner1 = """Welcome to Netsuite WS client interactive mode
Available vars:
`ns` - NetSuite client
`query` - run SuiteQL sync
Example usage:
soap_results = await ns.soap_api.getList('customer', internalIds=[1337])
restlet_results = await ns.restlet.get(987, deploy=2)
rest_api_results = await ns.rest_api.get("/record/v1/salesOrder")
ns.rest_api._default_timeout = 60 * 5
catalog = await ns.rest_api.openapi()
query_results = await ns.rest_api.suiteql("SELECT * FROM salesOrder")
query_results = query("SELECT * FROM salesOrder")
"""

IPython.embed(
user_ns=user_ns,
banner1=banner1,
config=traitlets.config.Config(colors="LightBG"),
# To fix no colored input we pass in `using=False`
# See: https://github.com/ipython/ipython/issues/11523
# TODO: Remove once this is fixed upstream
using=False,
)
print(banner1)
IPython.start_ipython(argv=[], user_ns=user_ns)

0 comments on commit 896be6f

Please sign in to comment.