# How can i invoke the CLI programmatically to run it in debug mode and step through the code?

**URL:** https://discourse.greatexpectations.io/t/how-can-i-invoke-the-cli-programmatically-to-run-it-in-debug-mode-and-step-through-the-code/501
**Category:** Archive
**Created:** [November 17, 2020, 8:55am UTC](https://discourse.greatexpectations.io/t/how-can-i-invoke-the-cli-programmatically-to-run-it-in-debug-mode-and-step-through-the-code/501 "2020-11-17T08:55:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![eugene.mandel](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/eugene.mandel/32/22_2.png) [@eugene.mandel](https://discourse.greatexpectations.io/u/eugene.mandel)
#### Post date: [November 17, 2020, 8:55am UTC](https://discourse.greatexpectations.io/t/how-can-i-invoke-the-cli-programmatically-to-run-it-in-debug-mode-and-step-through-the-code/501/1 "2020-11-17T08:55:52Z")

</div>

Sometimes it is helpful to run a Great Expectations CLI command programmatically in order to run in debug mode and step through the code. This is relevant especially when you consider contributing an improvement or a bug fix, or just want to understand deeper how it works.

How can this be done?

---

<div class="post-metadata">

### Author: ![eugene.mandel](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/eugene.mandel/32/22_2.png) [@eugene.mandel](https://discourse.greatexpectations.io/u/eugene.mandel)
#### Post date: [November 17, 2020, 9:03am UTC](https://discourse.greatexpectations.io/t/how-can-i-invoke-the-cli-programmatically-to-run-it-in-debug-mode-and-step-through-the-code/501/2 "2020-11-17T09:03:11Z")

</div>

Great Expectations CLI uses [click](https://pypi.org/project/click/) - a module for building Python CLIs.

Click provides CliRunner in its testing submodule that can be used to run a CLI command programmatically. Below is an example of running the equivalent of “`great_expectations suite scaffold mynewsuitename`” command programmatically. Notice how you can also provide the answers to interactive prompts.

> from click.testing import CliRunner  
> from great\_expectations.cli import cli
> 
> target\_directory = “the path to the directory with my great\_expectations.yml” config file
> 
> runner = CliRunner(mix\_stderr=False)
> 
> result = runner.invoke(  
> cli,  
> [“suite”, “scaffold”, “mynewsuitename”, “-d”, target\_directory],  
> input=“1\nselect \* from my\_table limit 1000”,  
> catch\_exceptions=False,  
> )
