tmrts / boilr

:zap: boilerplate template manager that generates files or directories from template repositories
Apache License 2.0
1.72k stars 118 forks source link

Current error messages are not helpful #27

Open Aluriak opened 8 years ago

Aluriak commented 8 years ago

The API feels very heavy to me : laconic outputs, and at least 5 words for most used commands (!).

The problem have a good illustration here:

>boilr template use mytemplate
[✘] not enough arguments

This is annoying, because i have to forge again a long line in order to understand why:

>boilr template use --help

And finally forge the full line (which is exactly what i type before… except a dot):

>boilr template use mytemplate .

The common practice to avoid the first problem is to print the help directly, eventually with an error message like [✘] not enough arguments. A compromise could be to print something like [✘] not enough arguments (expected: 'boilr template use <template> <dir>'), which gives a big hint about missing & misplaced arguments.

Fixing the second problem can be done (user-side) by adding shell shortcuts, like function blues() {~/bin/boilr template use $1 .}, or by providing them in the API directly:

> boilr save mytemplate
> boilr use mytemplate

Or, just by use working directory if no path is provided:

> boilr template save mytemplate
> boilr template use mytemplate

In both cases, the idea is to provides shortcuts for most common calls. Chances are peoples mostly want to register and use templates in current directory.

Also, the fact that boilr template save and boilr template use don't expect arguments in the same order is… unexpected.

tmrts commented 8 years ago

@Aluriak thanks for the detailed report, TODO items for better error messages and aliases were sitting in my TODO list for a while, but now that boilr started having users, I'll resolve them :+1:

Aluriak commented 8 years ago

Thank you for support. I don't know anything in Go, so will probably not interact with the source code.

However, this issue is more a remark than a problem. As i said, with proper aliases the API become very lighweight.

tmrts commented 8 years ago

@Aluriak that's quite alright, participation is a much more valuable contribution to me than code 😄

I see no obstacle to providing a prompt for Do you want boilr aliases to be configured?(y/N) and improving the user experience, it's a good suggestion :+1:

Aluriak commented 8 years ago

I don't know how to manage properly that option, which could be useful if the main API is not updated.

However, just some indication/advices on the README could be enough. Peoples that don't like typing long commands are the most involved in aliasing, and already know what to do.

Follows the bash-compliant code i've added to my sources.

# Alias for 'boilr template use $1 .'
function boilr_use_shortcut() {
    ~/bin/boilr template use $1 . ${@:2}
}
# Alias for 'boilr template save . $1'
function boilr_save_shortcut() {
    ~/bin/boilr template save . $@
}

alias boilr='~/bin/boilr'
alias bs='boilr_save_shortcut'
alias bu='boilr_use_shortcut'

Usage:

bs python  # save project in working directory
bu python  # create project in working directory