diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2018-10-04 01:00:25 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2018-10-04 01:00:25 +0200 |
| commit | e9bad489128dd526b44b08cc3bed6cce1cb731da (patch) | |
| tree | 85eda351ea985e240cedf831c1c86111fc4a6c5e /interact.go | |
| parent | a4a53949409944ae1745a8ab16901fb9a21ac7c4 (diff) | |
new getNewInput
Diffstat (limited to 'interact.go')
| -rw-r--r-- | interact.go | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/interact.go b/interact.go index 906d221..67e7f15 100644 --- a/interact.go +++ b/interact.go @@ -283,8 +283,13 @@ func interact() { c.Println(boldRed(arg,"is not a valid id!")) } }else{ - c.Println(boldRed("editcustomer <id> - Please enter an id")) - allCustomers() + selids,lids := getCustomerList() + choice := c.MultiChoice(lids,"Select a Customer to Edit") + if choice > -1 { + editCustomer(selids[choice]) + } + //c.Println(boldRed("editcustomer <id> - Please enter an id")) + //allCustomers() } c.Println(promptcol("______________________")) }, @@ -355,6 +360,17 @@ func interact() { }) shell.AddCmd(&ishell.Cmd{ + Name: "allcustomers", + Help: "Show all Customers", + LongHelp: ` Usage: allcustomers + Show all Customers.`, + Func: func(c *ishell.Context) { + allCustomers() + c.Println(promptcol("______________________")) + }, + }) + + shell.AddCmd(&ishell.Cmd{ Name: "showbills", Help: "<n> - Show the last n bills", LongHelp: ` Usage: showbills <n> @@ -659,9 +675,7 @@ func isInterSure(question string) (bool) { } func getInterInput(question string) (out string) { - shell := ishell.New() - //shell.SetMultiChoicePrompt(" ->"," - ") - //shell.SetChecklistOptions("[ ] ","[X] ") + shell := ishell.New() shell.ShowPrompt(false) defer shell.ShowPrompt(true) @@ -671,6 +685,24 @@ func getInterInput(question string) (out string) { return } +func getNewInterInput(question,old string) (string) { + shell := ishell.New() + shell.ShowPrompt(false) + defer shell.ShowPrompt(true) + + if old != "" { + shell.Println("Current:",old) + } + shell.Print(question) + line := shell.ReadLine() + + if line == "" { + return old + }else{ + return line + } +} + func multichoice(about string) { shell := ishell.New() |
