title: Call a click command from code
body: <p>I have a function which is wrapped as a command using <a href="http://click.pocoo.org/5/" rel="noreferrer">click</a>. So it looks like this:</p>
  
  <pre><code>@click.command()
  @click.option('-w', '--width', type=int, help="Some helping message", default=0)
  [... some other options ...]
  def app(width, [... some other option arguments...]):
      [... function code...]
  </code></pre>
  
  <p>I have different use cases for this function. Sometimes, calling it through the command line is fine, but sometime I would also like to call directly the function</p>
  
  <pre><code>from file_name import app
  width = 45
  app(45, [... other arguments ...]) 
  </code></pre>
  
  <p>How can we do that? How can we call a function that has been wrapped as a command using click? I found this <a href="https://stackoverflow.com/questions/40091347/call-another-click-command-from-a-click-command">related post</a>, but it is not clear to me how to adapt it to my case (i.e., build a Context class from scratch and use it outside of a click command function).</p>
  
  <p><strong>EDIT:</strong> I should have mentioned: I cannot (easily) modify the package that contains the function to call. So the solution I am looking for is how to deal with it from the caller side.</p>