CLI Options

Sparta applications delegate func main() responsibilities to one of Sparta’s Main entrypoints (Main, MainEx). This provides each application with some standard command line options as shown below:

$ go run main.go --help
Simple Sparta application that demonstrates core functionality

Usage:
  main [command]

Available Commands:
  delete      Delete service
  describe    Describe service
  execute     Start the application and begin handling events
  explore     Interactively explore a provisioned service
  help        Help about any command
  profile     Interactively examine service pprof output
  provision   Provision service
  status      Produce a report for a provisioned service
  version     Display version information

Flags:
  -f, --format string    Log format [text, json] (default "text")
  -h, --help             help for main
      --ldflags string   Go linker string definition flags (https://golang.org/cmd/link/)
  -l, --level string     Log level [panic, fatal, error, warn, info, debug] (default "info")
      --nocolor          Boolean flag to suppress colorized TTY output
  -n, --noop             Dry-run behavior only (do not perform mutations)
  -t, --tags string      Optional build tags for conditional compilation
  -z, --timestamps       Include UTC timestamp log line prefix

Use "main [command] --help" for more information about a command.

```

It's also possible to add [custom flags](/reference/application/custom_flags) and/or [custom commands](/reference/application/custom_commands) to extend your application's behavior.

These command line options are briefly described in the following sections. For the most up to date information, use the `--help` subcommand option.


# Standard Commands

## Delete

This simply deletes the stack (if present). Attempting to delete a non-empty stack is not treated as an error.

## Describe

The `describe` command line option produces an HTML summary (see [graph.html](/images/overview/graph.html) for an example) of your Sparta service.

The report also includes the automatically generated CloudFormation template which can be helpful when diagnosing provisioning errors.

## Execute

This command is used when the cross compiled binary is provisioned in AWS lambda. It is not (typically) applicable to the local development workflow.

## Explore

The `explore` option creates a terminal GUI that supports interactive exploration of lambda functions deployed to AWS. This ui recursively searches for all _*.json_ files in the source tree to populate the set of eligible events that can be submitted.

![Explore](/images/explore.jpg "Explore")

## Profile

The `profile` command line option enters an interactive session where a previously profiled application can be locally visualized using snapshots posted to S3 and provided to a local [pprof ui](https://rakyll.org/pprof-ui/).

## Provision

The `provision` option is the subcommand most likely to be used during development.  It provisions the Sparta application to AWS Lambda.

## Status

The `status` option queries AWS for the current stack status
and produces an optionally account-id redacted report. Stack
outputs, tags, and other metadata are included in the status report:

<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ go run main.go status --redact
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ════════════════════════════════════════════════
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ╔═╗╔═╗╔═╗╦═╗╔╦╗╔═╗   Version : <span style="color:#ae81ff">1</span>.5.0
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ╚═╗╠═╝╠═╣╠╦╝ ║ ╠═╣   SHA     : 8f199e1
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ╚═╝╩  ╩ ╩╩╚═ ╩ ╩ ╩   Go      : go1.11.1
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ════════════════════════════════════════════════
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> Service: MyHelloWorldStack-mweagle            LinkFlags<span style="color:#f92672">=</span> Option<span style="color:#f92672">=</span>status UTC<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2018-10-14T12:28:18Z&#34;</span>
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ════════════════════════════════════════════════
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0001</span><span style="color:#f92672">]</span> StackId                                       Id<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;arn:aws:cloudformation:us-west-2:************:stack/MyHelloWorldStack-mweagle/5817dff0-c5f1-11e8-b43a-503ac9841a99&#34;</span>
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0001</span><span style="color:#f92672">]</span> Stack status                                  State<span style="color:#f92672">=</span>UPDATE_COMPLETE
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0001</span><span style="color:#f92672">]</span> Created                                       Time<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2018-10-02 03:14:59.127 +0000 UTC&#34;</span>
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0001</span><span style="color:#f92672">]</span> Last Update                                   Time<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2018-10-06 14:20:40.267 +0000 UTC&#34;</span>
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0001</span><span style="color:#f92672">]</span> Tag                                           io:gosparta:buildId<span style="color:#f92672">=</span>7ee3e1bc52f15c4a636e05061eaec7b748db22a9</code></pre></div>



## Version

The `version` option is a diagnostic command that prints the version of the Sparta framework embedded in the application.

<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ go run main.go version
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ════════════════════════════════════════════════
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ╔═╗╔═╗╔═╗╦═╗╔╦╗╔═╗   Version : <span style="color:#ae81ff">1</span>.5.0
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ╚═╗╠═╝╠═╣╠╦╝ ║ ╠═╣   SHA     : 8f199e1
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ╚═╝╩  ╩ ╩╩╚═ ╩ ╩ ╩   Go      : go1.11.1
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ════════════════════════════════════════════════
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> Service: MyHelloWorldStack-mweagle            LinkFlags<span style="color:#f92672">=</span> Option<span style="color:#f92672">=</span>version UTC<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2018-10-14T12:27:36Z&#34;</span>
INFO<span style="color:#f92672">[</span><span style="color:#ae81ff">0000</span><span style="color:#f92672">]</span> ════════════════════════════════════════════════</code></pre></div>