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

  main [command]

Available Commands:
  delete      Delete service
  describe    Describe service
  execute     Execute
  explore     Interactively explore service
  help        Help about any command
  profile     Interactively examine service pprof output
  provision   Provision service
  version     Display version information

  -f, --format string    Log format [text, json] (default "text")
  -h, --help             help for main
      --ldflags string   Go linker string definition flags (
  -l, --level string     Log level [panic, fatal, error, warn, info, debug] (default "info")
  -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

It’s also possible to add custom flags and/or 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


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


The describe command line option produces an HTML summary (see 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.


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


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.



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.


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


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

$ go run main.go version
INFO[0000] ════════════════════════════════════════════════
INFO[0000] ╔═╗┌─┐┌─┐┬─┐┌┬┐┌─┐   Version : 1.2.1
INFO[0000] ╚═╗├─┘├─┤├┬┘ │ ├─┤   SHA     : b76b71d
INFO[0000] ╚═╝┴  ┴ ┴┴└─ ┴ ┴ ┴   Go      : go1.10
INFO[0000] ════════════════════════════════════════════════
INFO[0000] Service: MyHelloWorldStack-mweagle            LinkFlags= Option=version UTC="2018-07-20T04:44:17Z"
INFO[0000] ════════════════════════════════════════════════