From 66f92ff59b5254741adf97a4459942603980cf46 Mon Sep 17 00:00:00 2001 From: mkideal Date: Sat, 11 Aug 2018 18:05:37 +0800 Subject: [PATCH] add builtin ENV: __EXEC_FILENAME for getting executable filename. see issue #40 --- _examples/027-global-option/main.go | 2 +- _examples/027-global-option/run.sh | 4 ++-- flag.go | 28 ++++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/_examples/027-global-option/main.go b/_examples/027-global-option/main.go index d185124..6690d7c 100644 --- a/_examples/027-global-option/main.go +++ b/_examples/027-global-option/main.go @@ -16,7 +16,7 @@ func main() { // root command type rootT struct { cli.Helper - Self *rootT `json:"-" cli:"c,config" usage:"config" parser:"jsonfile" dft:"1.json"` + Self *rootT `json:"-" cli:"c,config" usage:"config" parser:"jsonfile" dft:"$__EXEC_FILENAME.json"` Host string `cli:"H,host" usage:"host addr" dft:"$HOST"` Port int `cli:"p,port" usage:"listening port"` } diff --git a/_examples/027-global-option/run.sh b/_examples/027-global-option/run.sh index 4c3d27b..3c9aa65 100755 --- a/_examples/027-global-option/run.sh +++ b/_examples/027-global-option/run.sh @@ -4,7 +4,7 @@ set -e go build -o app -cat >1.json<app.json<