Skip to content
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

todo and todo list show different results #237

Open
WhyNotHugo opened this issue Apr 20, 2017 · 6 comments
Open

todo and todo list show different results #237

WhyNotHugo opened this issue Apr 20, 2017 · 6 comments
Assignees
Labels

Comments

@WhyNotHugo
Copy link
Member

Due to the way we call the default command, callbacks aren't being run, so _validate_startable_param will never run. We already have hacks in place due to this scenario, so we really need to start looking at how we're implementing this.

@WhyNotHugo WhyNotHugo added the bug label Apr 20, 2017
@WhyNotHugo WhyNotHugo self-assigned this Apr 20, 2017
@untitaker
Copy link
Member

I don't understand what you mean here. Could you give an example invocation/config where those behave differently?

@WhyNotHugo
Copy link
Member Author

todo list --startable and todo --startable yield different results, since the latter won't forward the --startable flag to the list command.

@untitaker
Copy link
Member

I don't think this is cleanly implementable in Click.

@WhyNotHugo
Copy link
Member Author

#238 goes halfway there, but there are other issues (--porcelain --startable) ignores the first flag.

@aleprovencio
Copy link

aleprovencio commented Mar 5, 2018

I've also noticed that when startable option is set to true on todoman.conf, the --start option returns wrong results.

@Pikrass
Copy link
Contributor

Pikrass commented Aug 6, 2018

I think my issue is related to this one.

I have startable=true in my config file. todo list correctly hides non-startable tasks, but todo does not.

I hacked it so that startable was correctly passed to the list subcommand, but then I had no way to display non-startable tasks. So I added a --no-startable option.

This is still not perfect: I'd like a way to show only non-startable tasks (with a --unstartable perhaps?). But that'd be more of a feature than a fix.

Here's my hack's patch. There's probably a cleaner way to do this. (I also fixed a typo in --startable's help message).

--- cli.py	2018-08-06 19:41:50.206590030 +0200
+++ /usr/lib/python3/dist-packages/todoman/cli.py	2018-08-06 20:01:14.562939507 +0200
@@ -109,11 +109,6 @@
         raise click.BadParameter(e)
 
 
-def _validate_startable_param(ctx, param, val):
-    ctx = ctx.find_object(AppContext)
-    return val or ctx.config['main']['startable']
-
-
 def _validate_todos(ctx, param, val):
     ctx = ctx.find_object(AppContext)
     with handle_error():
@@ -592,12 +587,11 @@
     help='Only shows tasks before/after given DATE'
 )
 @click.option(
-    '--startable',
+    '--startable/--no-startable',
     default=None,
     is_flag=True,
-    callback=_validate_startable_param,
     help='Show only todos which '
-    'should can be started today (i.e.: start time is not in the '
+    'can be started today (i.e.: start time is not in the '
     'future).'
 )
 @click.option(
@@ -628,5 +622,8 @@
     The following commands can further filter shown todos, or include those
     omited by default:
     """
+    if kwargs['startable'] is None:  # False means explicitly disabled
+        kwargs['startable'] = ctx.config['main']['startable']
+
     todos = ctx.db.todos(**kwargs)
     click.echo(ctx.formatter.compact_multiple(todos))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants