title: Optional CLI arguments with python Click library option
body: <p>I'm having a conundrum with the Python <a href="https://click.palletsprojects.com/en/7.x/" rel="noreferrer">Click</a> library when parsing some CLI options.</p>
  
  <p>I would like an option to act as a flag by itself, but optionally accept string values. E.g.:</p>
  
  <ol>
  <li><p><code>$ myscript</code> ⇒ option = False</p></li>
  <li><p><code>$ myscript -o</code> ⇒ option = True</p></li>
  <li><p><code>$ myscript -o foobar</code> ⇒ option = Foobar</p></li>
  </ol>
  
  <p>Additionally, I would like the option to be "eager" (e.g. in "Click" terms abort execution after a callback), but this can be ignored for now.</p>
  
  <hr>
  
  <p>When I define my arguments like this:</p>
  
  <pre><code>@click.command()
  @click...
  @click.option("-o", "option", is_flag=True, default=False)
  def myscript(..., option):
  </code></pre>
  
  <p>I achieve example 1 and 2, but 3 is naturally impossible because the flag detects present/not present only.</p>
  
  <hr>
  
  <p>When I define my arguments like this:</p>
  
  <pre><code>@click.command()
  @click...
  @click.option("-o", "--option", default="") # Let's assume I will cast empty string to False
  def myscript(..., option):
  </code></pre>
  
  <p>I achieve 1 and 3, but 2 will fail with an <code>Error: -c option requires an argument</code>.</p>
  
  <hr>
  
  <p>This does not seems like an out-of-this world scenario, but I can't seem to be able to achieve this or find examples that behave like this.</p>
  
  <p>How can I define an <code>@click.option</code> that gets parsed like:</p>
  
  <ul>
  <li><code>False</code> when not set</li>
  <li><code>True</code> when set but without value</li>
  <li><code>str</code> when set with value</li>
  </ul>