Skip to content

Commit

Permalink
Minor help test correcion. The build time is visible now always.
Browse files Browse the repository at this point in the history
  • Loading branch information
rokath committed Mar 21, 2024
1 parent b3047c5 commit e0f5639
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
13 changes: 10 additions & 3 deletions internal/args/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/args/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions internal/args/tricehelpall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e0f5639

Please sign in to comment.