Skip to content

Commit

Permalink
feat: add --notebook flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Caceresenzo committed May 1, 2023
1 parent 71b9f82 commit 0bcdc87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crunch/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'crunch-cli'
__description__ = 'crunch-cli - CLI of the CrunchDAO Platform'
__version__ = '0.15.2'
__version__ = '0.16.0'
__author__ = 'Enzo CACERES'
__author_email__ = '[email protected]'
__url__ = 'https://github.com/crunchdao/crunch-cli'
5 changes: 4 additions & 1 deletion crunch/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
@click.option("--debug", "enable_debug", envvar="CRUNCH_DEBUG", is_flag=True, help="Enable debug output.")
@click.option("--api-base-url", envvar="API_BASE_URL", required=True, help="Set the API base url.")
@click.option("--web-base-url", envvar="WEB_BASE_URL", required=True, help="Set the Web base url.")
@click.option("--notebook", is_flag=True, help="Tell the CLI you are running the command while inside a notebook.")
def cli(
enable_debug: bool,
api_base_url: str,
web_base_url: str,
notebook: bool,
):
global debug
debug = enable_debug
Expand All @@ -24,7 +26,8 @@ def cli(
session = utils.CustomSession(
web_base_url,
api_base_url,
debug
debug,
notebook,
)


Expand Down
7 changes: 5 additions & 2 deletions crunch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
class CustomSession(requests.Session):
# https://stackoverflow.com/a/51026159/7292958

def __init__(self, web_base_url=None, api_base_url=None, debug=False):
def __init__(self, web_base_url=None, api_base_url=None, debug=False, notebook=False):
super().__init__()
self.web_base_url = web_base_url
self.api_base_url = api_base_url
self.debug = debug
self.notebook = notebook

def request(self, method, url, *args, **kwargs):
response = super().request(
Expand Down Expand Up @@ -61,9 +62,11 @@ def format_web_url(self, path: str):
)

def print_recopy_command(self):
tab = "notebook" if self.notebook else "cli"

print("---")
print("please follow this link to copy and paste your new setup command:")
print(self.format_web_url('/submit?tab=cli'))
print(self.format_web_url(f'/submit?tab={tab}'))
print("")


Expand Down

0 comments on commit 0bcdc87

Please sign in to comment.