terminal: Implements init file and source command

The 'source' command reads the file specified as argument and executes
it as a list of delve commands.
Additionally a flag '--init' can be passed to delve specifying a file
containing a list of commands to execute on startup.

Issue #96
This commit is contained in:
aarzilli
2015-09-29 18:40:12 +02:00
committed by Derek Parker
parent bc9ac0ec78
commit eb2bc2a7ee
6 changed files with 107 additions and 7 deletions

View File

@ -26,6 +26,7 @@ type Term struct {
line *liner.State
conf *config.Config
dumb bool
InitFile string
}
func New(client service.Client, conf *config.Config) *Term {
@ -85,6 +86,13 @@ func (t *Term) Run() (error, int) {
f.Close()
fmt.Println("Type 'help' for list of commands.")
if t.InitFile != "" {
err := cmds.executeFile(t, t.InitFile)
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing init file: %s\n", err)
}
}
var status int
for {
cmdstr, err := t.promptForInput()