Commit ea99811f authored by Nik Khlestov's avatar Nik Khlestov

Standartization of project_id handling.

parent f2cd371a
import click
import sys
from click import MissingParameter
from .main import settings, session
@click.group()
@click.argument('project_id')
@click.option('--project-id', '-p', type=int, help='Project id, required if no pinned project.')
@click.pass_context
def package(ctx, project_id):
"""Work with packages in project."""
if settings.token is None:
ctx.fail('No authorization token provided.')
click.echo('No authorization token provided. Please login.')
sys.exit(1)
current_project_id = project_id or settings.project_id
if not current_project_id:
# Emulation of required parameter with possibility of pinning.
raise MissingParameter(param_hint=['--project-id', '-p'], param_type='option',
message='Please provide it or pin the project.')
ctx.obj = {
'project_id': project_id,
'project_id': project_id ,
}
......
......@@ -9,8 +9,8 @@ from .main import settings, session, PROJECT_CONFIG_FILE
def project():
"""Create, list, pin projects."""
if settings.token is None:
ctx = click.get_current_context()
ctx.fail('No authorization token provided.')
click.echo('No authorization token provided. Please login.')
sys.exit(1)
@project.command()
......@@ -26,7 +26,7 @@ def start(name):
@project.command()
@click.option('--project-id', '-i', required=True)
@click.option('--project-id', '-p', type=int, required=True)
def pin(project_id):
"""Set project as default (in the scope of directory)."""
with open(PROJECT_CONFIG_FILE, 'w') as ofile:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment