Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
update info to be more useful
Browse files Browse the repository at this point in the history
Signed-off-by: Jason McCallister <jason@craftcms.com>
  • Loading branch information
jasonmccallister committed Aug 10, 2020
1 parent 0458831 commit b4e9a81
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: install scripts

VERSION ?= 1.0.0-RC.2
VERSION ?= 1.0.0-RC2
NITRO_DEFAULT_MACHINE ?= nitro-dev

build:
Expand Down
38 changes: 34 additions & 4 deletions internal/cmd/info.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"

"github.com/craftcms/nitro/internal/config"
"github.com/craftcms/nitro/internal/nitro"
)

const infoTemplate = `Nitro installed, ready for something incredible at %s.
Add a project with "nitro add <directory>".
Server Information
-------------------------
IP address: %s
PHP version: %s
Need help setting up Xdebug?
https://github.com/craftcms/nitro/blob/master/XDEBUG.md
Need help using Nitro?
https://github.com/craftcms/nitro/blob/master/README.md`

var infoCommand = &cobra.Command{
Use: "info",
Short: "Show machine info",
RunE: func(cmd *cobra.Command, args []string) error {
machine := flagMachineName
runner := nitro.NewMultipassRunner("multipass")
ip := nitro.IP(machine, runner)
php := config.GetString("php", flagPhpVersion)

infoAction, err := nitro.Info(machine)
if err != nil {
return err
// check if the machine is running, if not start it
if ip == "" {
fmt.Println("The " + machine + " is not running...")
if err := startCommand.RunE(cmd, args); err != nil {
return err
}

// get the IP again
ip = nitro.IP(machine, runner)
}

return nitro.Run(nitro.NewMultipassRunner("multipass"), []nitro.Action{*infoAction})
fmt.Println(fmt.Sprintf(infoTemplate, ip, ip, php))
fmt.Println("")

return nil
},
}

0 comments on commit b4e9a81

Please # to comment.