|
|
|
|
@ -17,6 +17,12 @@ type UiServer struct {
|
|
|
|
|
ui packer.Ui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The arguments sent to Ui.Machine
|
|
|
|
|
type UiMachineArgs struct {
|
|
|
|
|
category string
|
|
|
|
|
args []string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *Ui) Ask(query string) (result string, err error) {
|
|
|
|
|
err = u.client.Call("Ui.Ask", query, &result)
|
|
|
|
|
return
|
|
|
|
|
@ -28,6 +34,17 @@ func (u *Ui) Error(message string) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *Ui) Machine(t string, args ...string) {
|
|
|
|
|
rpcArgs := &UiMachineArgs{
|
|
|
|
|
category: t,
|
|
|
|
|
args: args,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := u.client.Call("Ui.Message", rpcArgs, new(interface{})); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *Ui) Message(message string) {
|
|
|
|
|
if err := u.client.Call("Ui.Message", message, new(interface{})); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
@ -52,6 +69,13 @@ func (u *UiServer) Error(message *string, reply *interface{}) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *UiServer) Machine(args *UiMachineArgs, reply *interface{}) error {
|
|
|
|
|
u.ui.Machine(args.category, args.args...)
|
|
|
|
|
|
|
|
|
|
*reply = nil
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *UiServer) Message(message *string, reply *interface{}) error {
|
|
|
|
|
u.ui.Message(*message)
|
|
|
|
|
*reply = nil
|
|
|
|
|
|