From 7138b3be0b9c72c76439fc3827ebc4561869dfb4 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Tue, 8 Aug 2017 11:16:10 +0200 Subject: [PATCH] gopy: add -work switch to gopy-bind --- cmd_bind.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd_bind.go b/cmd_bind.go index 14e45c1..bee9872 100644 --- a/cmd_bind.go +++ b/cmd_bind.go @@ -34,6 +34,7 @@ ex: cmd.Flag.String("lang", defaultPyVersion, "python version to use for bindings (python2|py2|python3|py3)") cmd.Flag.String("output", "", "output directory for bindings") cmd.Flag.Bool("symbols", true, "include symbols in output") + cmd.Flag.Bool("work", false, "print the name of temporary work directory and do not delete it when exiting") return cmd } @@ -50,6 +51,7 @@ func gopyRunCmdBind(cmdr *commander.Command, args []string) error { odir := cmdr.Flag.Lookup("output").Value.Get().(string) lang := cmdr.Flag.Lookup("lang").Value.Get().(string) symbols := cmdr.Flag.Lookup("symbols").Value.Get().(bool) + printWork := cmdr.Flag.Lookup("work").Value.Get().(bool) cwd, err := os.Getwd() if err != nil { @@ -98,13 +100,17 @@ func gopyRunCmdBind(cmdr *commander.Command, args []string) error { if err != nil { return fmt.Errorf("gopy-bind: could not create temp-workdir (%v)", err) } - log.Printf("work: %s\n", work) + if printWork { + log.Printf("work: %s\n", work) + } err = os.MkdirAll(work, 0644) if err != nil { return fmt.Errorf("gopy-bind: could not create workdir (%v)", err) } - //defer os.RemoveAll(work) + if !printWork { + defer os.RemoveAll(work) + } err = genPkg(work, pkg, lang) if err != nil {