No such option, click version 6.6
<p>Using <a href="http://click.pocoo.org/5/" rel="nofollow">http://click.pocoo.org/5/</a></p>

<p>I have this command defined, however, when I run the command, the option missing is passed through correctly (I can see the value), but I get <code>Error: no such option: --missing</code> in the terminal and the command fails. </p>

<p>What am I doing wrong here exactly? The code below has had some information stripped from it to make it less overwhelming, but the logic is the same.</p>

<pre><code>@cli.group()
def migrator():
    """Migrator from existing HEPData System to new Version"""


@migrator.command()
@with_appcontext
@click.option('--missing', is_flag=True, help='...')
@click.option('--start', '-s', type=int, default=None, help='...')
@click.option('--end', '-e', default=None, type=int, help='...')
@click.option('--date', '-d', type=str, default=None, help='...')
def migrate(start, end, missing, date=None):
    """
    Migrates all content...
    """
    if missing:
        ids = get_missing_records()
    else:
        ids = get_all_ids_in_current_system(date)

    print("Found {} ids to load.".format(len(ids)))
    if start is not None:
        _slice = slice(int(start), end)
        ids = ids[_slice]
        print("Sliced, going to load {} records.".format(len(ids)))

    print(ids)

    load_files(ids)
</code></pre>

<p>I found the issue. Was nothing much to do with pocoo click. It was because the <code>get_missing_records()</code> function is actually another CLI command. The <code>missing</code> parameter is subsequently passed through to this function as well, and the <code>get_missing_records()</code> method obviously knows nothing about that parameter. So all solved.</p>

python click command-line-interface