Useful output with bare invocation & no root default task #180

Closed
bitprophet opened this Issue Sep 26, 2014 · 8 comments

Projects

None yet

4 participants

@bitprophet
Member

In the past we had empty output when one said invoke by itself (IIRC), then #165 happened and now it will pick up a default root task; but if there IS no default root task we just get a ValueError. It should probably do something useful like print core help or a task list.

@epicserve

A workaround until then is to add a task like this to your tasks file. However, the list task shows up in the task list. It would be nice if you could hide it some how.

@task(default=True)
def list():
    """List tasks"""
    run("invoke --list")
@bitprophet
Member

@epicserve I am curious though why you were even running invoke by itself :) it's not something I see users do super duper often (same with fab). It's important to have it behave "well" but at the same time I'm not sure why folks need a workaround exactly ;)

@epicserve

shrug I'm different/special I guess. :) I run commands all the time without arguments (ls, mkdir, pwd, workon, stree, ifconfig, pep8, ipython, pyflakes, setvirtualenvproject, virtualenvwrapper, etc).

@sophacles

I think it would be nice to display at least a minimal usage/help string...

Something like:

Usage: inv[oke] [--core-opts] task1 [--task1-opts] ... taskN [--taskN-opts]
For more information: invoke --help
To list available invokations: invoke --list

No default task set.

If there isn't a tasks.py, there should probably be a better error than:

Can't find any collection named None!

Probably a message like: (after the Usage strings)

Could not find a tasks.py file. Either run with -f or create a task file.

None of this is vital of course, but it's nice polish :)

@bitprophet
Member

I thought it did get updated to print a more useful "no collection found" msg? If not there's probably another ticket for it...

@sophacles

It does print a more useful message with no tasks.py -- I was looking at an old virtualenv.

@pekkaklarck

I'm new to Invoke and really like it so far. One of the biggest surprises has been the default behavior of showing a traceback when running just invoke, and I was even more surprised when I noticed that docs say it should be same as invoke --help:
http://docs.pyinvoke.org/en/latest/concepts/cli/intro.html

In other words, +1 from me to show help unless configured otherwise. Luckily I can easily emulate that behavior:

@task(default=True)
def help():
    """Show help, basically an alias for --help.

    Needed as a default task due to https://github.com/pyinvoke/invoke/issues/180
    """
    run('invoke --help')
@bitprophet
Member

Good catch re: the docs. I retain the right to change things at whim given it's pre 1.0, but clearly past-me thought help output was the sane default; and that's also Unix tradition much of the time, so yea. Let's do that.

@bitprophet bitprophet added a commit that referenced this issue Oct 1, 2014
@bitprophet bitprophet Changelog re #180, fixes #180 dd09d24
@bitprophet bitprophet closed this in dd09d24 Oct 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment