|
|
@@ -22,11 +22,11 @@ def sprint(ctx):
|
|
|
"""Handle sprints"""
|
|
|
ctx.obj['model'] = Sprint
|
|
|
|
|
|
-@click.command()
|
|
|
+@milestone.command('new')
|
|
|
@click.option('--name', prompt='Milestone name')
|
|
|
@click.option('--description', prompt='Milestone description')
|
|
|
@click.pass_context
|
|
|
-def new(ctx, name, description):
|
|
|
+def new_milestone(ctx, name, description):
|
|
|
"""Add a new milestone"""
|
|
|
model = ctx.obj['model']
|
|
|
data = {
|
|
|
@@ -35,21 +35,44 @@ def new(ctx, name, description):
|
|
|
}
|
|
|
ok, m_doc = model.validate(data)
|
|
|
if ok :
|
|
|
- m = model.create(m_doc)
|
|
|
+ m = model.get(m_doc)
|
|
|
+ click.secho(f"{m} was successfully added", fg='green')
|
|
|
+ m.save()
|
|
|
+ else:
|
|
|
+ click.secho(f"Errors : {m_doc}", fg='red')
|
|
|
+
|
|
|
+@sprint.command('new')
|
|
|
+@click.option('--name', prompt='Sprint name')
|
|
|
+@click.option('--description', prompt='Sprint description')
|
|
|
+@click.option('--milestone_id', prompt='Related milestone ID', type=int)
|
|
|
+@click.pass_context
|
|
|
+def new_sprint(ctx, name, description, milestone_id):
|
|
|
+ """Add a new sprint"""
|
|
|
+ model = ctx.obj['model']
|
|
|
+ data = {
|
|
|
+ 'name': name,
|
|
|
+ 'description': description,
|
|
|
+ 'milestone_id': milestone_id
|
|
|
+ }
|
|
|
+ ok, m_doc = model.validate(data)
|
|
|
+ if ok :
|
|
|
+ m = model.get(m_doc)
|
|
|
+ click.secho(f"{m} was successfully added", fg='green')
|
|
|
m.save()
|
|
|
+ else:
|
|
|
+ click.secho(f"Errors : {m_doc}", fg='red')
|
|
|
|
|
|
@click.command()
|
|
|
@click.pass_context
|
|
|
def list(ctx):
|
|
|
"""List"""
|
|
|
model = ctx.obj['model']
|
|
|
- click.echo(model.list())
|
|
|
+ list = model.list()
|
|
|
+ click.echo('\n'.join([i.__terminal__() for i in list]))
|
|
|
|
|
|
|
|
|
-milestone.add_command(new)
|
|
|
milestone.add_command(list)
|
|
|
|
|
|
-sprint.add_command(new)
|
|
|
sprint.add_command(list)
|
|
|
|
|
|
if __name__ == '__main__':
|