add docs and the option to list variables from inside the console
This commit is contained in:
@@ -191,6 +191,8 @@ func (s *REPLSession) Handle(line string) (string, error) {
|
||||
return "", ErrSessionExit
|
||||
case strings.TrimSpace(line) == "help":
|
||||
return s.handleHelp()
|
||||
case strings.TrimSpace(line) == "variables":
|
||||
return s.handleVariables()
|
||||
default:
|
||||
return s.handleEval(line)
|
||||
}
|
||||
@@ -205,6 +207,15 @@ func (s *REPLSession) handleEval(line string) (string, error) {
|
||||
return rendered, nil
|
||||
}
|
||||
|
||||
func (s *REPLSession) handleVariables() (string, error) {
|
||||
varsstring := "\n"
|
||||
for k, v := range s.Core.Context().UserVariables {
|
||||
varsstring += fmt.Sprintf("%s: %+v,\n", k, v)
|
||||
}
|
||||
|
||||
return varsstring, nil
|
||||
}
|
||||
|
||||
func (s *REPLSession) handleHelp() (string, error) {
|
||||
text := `
|
||||
The Packer console allows you to experiment with Packer interpolations.
|
||||
|
||||
Reference in New Issue
Block a user