github.com/jcarley/cli@v0.0.0-20180201210820-966d90434c30/commands/init/contract.go (about)

     1  package init
     2  
     3  import (
     4  	"github.com/Sirupsen/logrus"
     5  	"github.com/daticahealth/cli/lib/auth"
     6  	"github.com/daticahealth/cli/lib/prompts"
     7  	"github.com/daticahealth/cli/models"
     8  	"github.com/jault3/mow.cli"
     9  )
    10  
    11  // Cmd is the contract between the user and the CLI. This specifies the command
    12  // name, arguments, and required/optional arguments and flags for the command.
    13  var Cmd = models.Command{
    14  	Name:      "init",
    15  	ShortHelp: "Get started using the Datica platform",
    16  	LongHelp: "The <code>init</code> command walks you through setting up the CLI to use with the Datica platform. " +
    17  		"The <code>init</code> command requires you to have an environment already set up. ",
    18  	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
    19  		return func(cmd *cli.Cmd) {
    20  			cmd.Action = func() {
    21  				p := prompts.New()
    22  				if _, err := auth.New(settings, p).Signin(); err != nil {
    23  					logrus.Fatal(err.Error())
    24  				}
    25  				err := CmdInit(settings, p)
    26  				if err != nil {
    27  					logrus.Fatal(err.Error())
    28  				}
    29  			}
    30  		}
    31  	},
    32  }