diff --git a/internal/args/handler.go b/internal/args/handler.go index 820494d55..59d442a5a 100644 --- a/internal/args/handler.go +++ b/internal/args/handler.go @@ -32,9 +32,16 @@ func Handler(w io.Writer, fSys *afero.Afero, args []string) error { //id.FnJSON = id.FullFilePath(fSys, id.FnJSON) if Date == "" { // goreleaser will set Date, otherwise use file info. - fi, err := fSys.Stat(args[0]) - if nil == err { // On running main tests file-info is invalid, so do not use in that case. - Date = fi.ModTime().String() + path, err := os.Executable() + if err != nil { + Date = fmt.Sprint(err) // just in case, simply show the error + } else { + fi, err := fSys.Stat(path) + if err == nil { // On running main tests file-info is invalid, so do not use it in that case. + Date = fi.ModTime().String() + } else { + Date = fmt.Sprint(err) // just in case, simply show the error + } } } diff --git a/internal/args/init.go b/internal/args/init.go index 27d2a6808..57d3e785b 100644 --- a/internal/args/init.go +++ b/internal/args/init.go @@ -268,7 +268,7 @@ func flagBinaryLogfile(p *flag.FlagSet) { "none": no binary logfile (same as "off") "my/path/auto": Use as binary logfile name "my/path/2006-01-02_1504-05_trice.bin" with actual time. "my/path/" must exist. "filename": Any other string than "auto", "none" or "off" is treated as a filename. If the file exists, logs are appended. -All trice output of the appropriate subcommands is appended per default into the logfile trice additionally to the normal output. +All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output. Change the filename with "-binaryLogfile myName.bin" or switch logging off with "-binaryLogfile none". `) p.StringVar(&receiver.BinaryLogfileName, "blf", "off", "Short for binaryLogfile") @@ -280,7 +280,7 @@ func flagLogfile(p *flag.FlagSet) { "none": no logfile (same as "off") "my/path/auto": Use as logfile name "my/path/2006-01-02_1504-05_trice.log" with actual time. "my/path/" must exist. "filename": Any other string than "auto", "none" or "off" is treated as a filename. If the file exists, logs are appended. -All trice output of the appropriate subcommands is appended per default into the logfile trice additionally to the normal output. +All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output. Change the filename with "-logfile myName.txt" or switch logging off with "-logfile none". `) p.StringVar(&logfileName, "lf", "off", "Short for logfile") diff --git a/internal/args/tricehelpall_test.go b/internal/args/tricehelpall_test.go index 2b3a38caa..f8f0ae903 100644 --- a/internal/args/tricehelpall_test.go +++ b/internal/args/tricehelpall_test.go @@ -40,7 +40,7 @@ func TestHelpAll(t *testing.T) { "none": no logfile (same as "off") "my/path/auto": Use as logfile name "my/path/2006-01-02_1504-05_trice.log" with actual time. "my/path/" must exist. "filename": Any other string than "auto", "none" or "off" is treated as a filename. If the file exists, logs are appended. - All trice output of the appropriate subcommands is appended per default into the logfile trice additionally to the normal output. + All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output. Change the filename with "-logfile myName.txt" or switch logging off with "-logfile none". (default "off") sub-command 'h|help': For command line usage. @@ -74,7 +74,7 @@ sub-command 'h|help': For command line usage. "none": no logfile (same as "off") "my/path/auto": Use as logfile name "my/path/2006-01-02_1504-05_trice.log" with actual time. "my/path/" must exist. "filename": Any other string than "auto", "none" or "off" is treated as a filename. If the file exists, logs are appended. - All trice output of the appropriate subcommands is appended per default into the logfile trice additionally to the normal output. + All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output. Change the filename with "-logfile myName.txt" or switch logging off with "-logfile none". (default "off") -r Show r|refresh specific help. @@ -136,7 +136,7 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log "none": no binary logfile (same as "off") "my/path/auto": Use as binary logfile name "my/path/2006-01-02_1504-05_trice.bin" with actual time. "my/path/" must exist. "filename": Any other string than "auto", "none" or "off" is treated as a filename. If the file exists, logs are appended. - All trice output of the appropriate subcommands is appended per default into the logfile trice additionally to the normal output. + All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output. Change the filename with "-binaryLogfile myName.bin" or switch logging off with "-binaryLogfile none". (default "off") -blf string @@ -226,7 +226,7 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log "none": no logfile (same as "off") "my/path/auto": Use as logfile name "my/path/2006-01-02_1504-05_trice.log" with actual time. "my/path/" must exist. "filename": Any other string than "auto", "none" or "off" is treated as a filename. If the file exists, logs are appended. - All trice output of the appropriate subcommands is appended per default into the logfile trice additionally to the normal output. + All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output. Change the filename with "-logfile myName.txt" or switch logging off with "-logfile none". (default "off") -newlineIndent int @@ -425,7 +425,7 @@ sub-command 'ver|version': For displaying version information. "none": no logfile (same as "off") "my/path/auto": Use as logfile name "my/path/2006-01-02_1504-05_trice.log" with actual time. "my/path/" must exist. "filename": Any other string than "auto", "none" or "off" is treated as a filename. If the file exists, logs are appended. - All trice output of the appropriate subcommands is appended per default into the logfile trice additionally to the normal output. + All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output. Change the filename with "-logfile myName.txt" or switch logging off with "-logfile none". (default "off") -v short for verbose