(cfg packer.Evaluator)
| 129 | } |
| 130 | |
| 131 | func (c *ConsoleCommand) modeInteractive(cfg packer.Evaluator) int { |
| 132 | // Setup the UI so we can output directly to stdout |
| 133 | l, err := readline.NewEx(wrappedreadline.Override(&readline.Config{ |
| 134 | Prompt: "> ", |
| 135 | InterruptPrompt: "^C", |
| 136 | EOFPrompt: "exit", |
| 137 | HistorySearchFold: true, |
| 138 | })) |
| 139 | if err != nil { |
| 140 | c.Ui.Error(fmt.Sprintf( |
| 141 | "Error initializing console: %s", |
| 142 | err)) |
| 143 | return 1 |
| 144 | } |
| 145 | for { |
| 146 | // Read a line |
| 147 | line, err := l.Readline() |
| 148 | if err == readline.ErrInterrupt { |
| 149 | if len(line) == 0 { |
| 150 | break |
| 151 | } else { |
| 152 | continue |
| 153 | } |
| 154 | } else if err == io.EOF { |
| 155 | break |
| 156 | } |
| 157 | out, exit, diags := cfg.EvaluateExpression(line) |
| 158 | ret := writeDiags(c.Ui, nil, diags) |
| 159 | if exit { |
| 160 | return ret |
| 161 | } |
| 162 | c.Ui.Say(out) |
| 163 | if exit { |
| 164 | return ret |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | return 0 |
| 169 | } |
no test coverage detected