Invoke: task name with underscore doesn't work properly

Created on 23 Nov 2017  路  2Comments  路  Source: pyinvoke/invoke

Say we have a task

@task
def store_configs(_, host='consul', port=8500, conf_yml='consuled_conf.yml'):
    c = Consul(host, port)
    conf = yaml.load(open(conf_yml))
    for k, v in conf['configs'].items():
        c.kv[conf['prefix'] + '/' + k] = v

if I run invoke store_configs, the following error shows up:

No idea what 'store_configs' is!

in order to invoke it I must do following:

invoke store-configs

Which isn't obvious. I think there are two option:

  1. Fix it so that we cat run command with underscore which is preferable
  2. Create explisit note in documentation

Most helpful comment

The behavior was intentionally changed (I think in 0.20.0). Can't comment on reasoning. Anyway, if you want to restore the original behavior, there is auto_dash_names flag that you can disable. For example in ~/.invoke.yaml:

tasks:
    auto_dash_names: false

Be sure to use 0.20.2+ for there was a bug regarding this option (https://github.com/pyinvoke/invoke/issues/465).

All 2 comments

BTW, it used to work in prevous versions

The behavior was intentionally changed (I think in 0.20.0). Can't comment on reasoning. Anyway, if you want to restore the original behavior, there is auto_dash_names flag that you can disable. For example in ~/.invoke.yaml:

tasks:
    auto_dash_names: false

Be sure to use 0.20.2+ for there was a bug regarding this option (https://github.com/pyinvoke/invoke/issues/465).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PatrickMassot picture PatrickMassot  路  6Comments

bitprophet picture bitprophet  路  4Comments

zaiste picture zaiste  路  9Comments

brejoc picture brejoc  路  8Comments

hindman picture hindman  路  12Comments