-
Notifications
You must be signed in to change notification settings - Fork 593
[CLI] Add init command and config util #5004
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
Conversation
cli/casp/src/casp/commands/init.py
Outdated
| import click | ||
|
|
||
| @click.command(name='init', help='Initializes the CLI') | ||
| from ..utils import config |
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.
Is there a way to have the absolute path instead?
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.
Done
| """Initializes the CLI by checking the Docker setup and pulling the | ||
| required image.""" | ||
| click.echo('Checking Docker setup...') | ||
| if not docker_utils.check_docker_setup(): |
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.
Could you extract this steps to auxiliary functions, like: _check_docker, _setup_credentials and so on?
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.
Sure! Done.
cli/casp/src/casp/commands/init.py
Outdated
| f'Custom config path "{custom_config_path}" does not exist. ' | ||
| 'Skipping.', | ||
| fg='yellow') | ||
| else: |
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.
Nit: you could have some early returns in this method to avoid these many if-elses
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.
Done.
Changes
This PR introduces the
casp initcommand, which performs the essential first-time setup for the CLI tool.Key Changes:
gcloud application-defaultcredentials, exiting with a clear error message if either is missing.~/.casp/config.json, saving the path to the gcloud credentials and an optional custom config path provided by the user.Demo
Here's a screenshot of

casp initin action: