1. import click
  2. @click.command()
  3. @click.option('--foo', help='the foo arg')
  4. @click.option('--bar', help='the bar arg')
  5. def main(**kwargs):
  6. """docstirng of main
  7. """
  8. return kwargs
  9. if __name__ == "__main__":
  10. main()

1command.callback

  1. from a import main
  2. main.callback(foo=111, bar=222)
  3. # {'foo': 111, 'bar': 222}

2 standalone_mode=False

  1. from a import main
  2. main(['--foo', 111, '--bar', 222], standalone_mode=False)
  3. # {'foo': '111', 'bar': '222'}