title: Where should I implement flask custom commands (cli)
body: <p>Creating custom commands in flask needs access to the app, which is generally created in <code>app.py</code> like this:</p>
  
  <pre class="lang-py prettyprint-override"><code>import click
  from flask import Flask
  
  app = Flask(__name__)
  
  @app.cli.command("create-user")
  @click.argument("name")
  def create_user(name):
      ...
  </code></pre>
  
  <p>However, in order not to bloat my app.py, I want to put my custom commands in a separate file e.g. <code>commands.py</code>, but this doesn't work because the entrypoint to my project is <code>app.py</code>, so I'll have to import app in <code>commands.py</code>and import my commands in <code>app.py</code> which results in a circular import error.</p>
  
  <p>How can I create custom commands in separate files ?</p>