add demote command
This commit is contained in:
parent
f4e1a5f94d
commit
24c104a7d8
2 changed files with 36 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
,Unnamed: 0.1,Unnamed: 0,STATUS,ID,TITLE,DETAILS,TAG,DEADLINE
|
,Unnamed: 0.4,Unnamed: 0.3,Unnamed: 0.2,Unnamed: 0.1,Unnamed: 0,STATUS,ID,TITLE,DETAILS,TAG,DEADLINE
|
||||||
0,0,0,DOING,1,print card,pretty print fixed-width cards given a content,klyban,
|
0,0,0,0,0,0,DOING,1,print card,pretty print fixed-width cards given a content,klyban,
|
||||||
1,1,1,DONE,2,print table,pretty print set of cards on each column,klyban,
|
1,1,1,1,1,1,TODO,2,print table,pretty print set of cards on each column,klyban,
|
||||||
2,2,2,TODO,3,nested prints,print cards within cards,klyban,
|
2,2,2,2,2,2,TODO,3,nested prints,print cards within cards,klyban,
|
||||||
|
|
|
||||||
|
32
klyban.py
32
klyban.py
|
|
@ -89,7 +89,7 @@ def show(context):
|
||||||
def promote(context, id):
|
def promote(context, id):
|
||||||
"""Upgrade the status of task `ID` to the next one.
|
"""Upgrade the status of task `ID` to the next one.
|
||||||
|
|
||||||
As configured with --status-list."""
|
Use status configured with --status-list."""
|
||||||
|
|
||||||
df = load_data(context)
|
df = load_data(context)
|
||||||
|
|
||||||
|
|
@ -112,6 +112,36 @@ def promote(context, id):
|
||||||
|
|
||||||
context.invoke(show)
|
context.invoke(show)
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
@click.argument('ID')
|
||||||
|
@click.pass_context
|
||||||
|
def demote(context, id):
|
||||||
|
"""Downgrade the status of task `ID` to the previous one.
|
||||||
|
|
||||||
|
Use status configured with --status-list."""
|
||||||
|
|
||||||
|
df = load_data(context)
|
||||||
|
|
||||||
|
row = df.loc[ df[context.obj['id_key']] == int(id) ]
|
||||||
|
if row.empty:
|
||||||
|
error("ID_NOT_FOUND", "{} = {} not found in `{}`".format(context.obj['id_key'], id, context.obj['input']))
|
||||||
|
|
||||||
|
i=0
|
||||||
|
for i in range(len(context.obj['status_list'])):
|
||||||
|
if row[context.obj['status_key']][1] == context.obj['status_list'][i]:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
if i == 0:
|
||||||
|
error("UNKNOWN_STATUS", "Cannot demote task {}, already at the first status.".format(id))
|
||||||
|
else:
|
||||||
|
df.loc[df[context.obj['id_key']] == int(id), context.obj['status_key']] = context.obj['status_list'][i-1]
|
||||||
|
|
||||||
|
save_data(context, df)
|
||||||
|
|
||||||
|
context.invoke(show)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue