From 3199e25c389057c9de9c3f67d0b412f077fd73f8 Mon Sep 17 00:00:00 2001 From: surdeus Date: Fri, 24 Mar 2023 19:35:14 +0300 Subject: [PATCH] ... --- src/mtool/main.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mtool/main.go b/src/mtool/main.go index d3baf82..3e58b38 100644 --- a/src/mtool/main.go +++ b/src/mtool/main.go @@ -10,6 +10,8 @@ import( type Flags struct { *flag.FlagSet + progName string + utilName string args []string parsedArgs []string } @@ -32,6 +34,14 @@ func (flags *Flags) Args() []string { return flags.parsedArgs } +func (flags *Flags) ProgName() string { + return flags.progName +} + +func (flags *Flags) UtilName() string { + return flags.utilName +} + func Main(name string, m Tools) { var( utilName string @@ -75,9 +85,7 @@ func Main(name string, m Tools) { arg1 := os.Args[1] flagSet := flag.NewFlagSet(arg1, flag.ExitOnError) flags := &Flags{ - flagSet, - []string{}, - []string{}, + FlagSet : flagSet, } flags.Usage = func() { out := flags.Output() @@ -115,6 +123,8 @@ func Main(name string, m Tools) { os.Exit(1) } + flags.progName = name + flags.utilName = args[0] flags.args = args[1:] util.Handler(flags)