-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version information in build and improve arg parsing
- Loading branch information
1 parent
6b1e0a4
commit a81c6de
Showing
3 changed files
with
44 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,42 @@ | ||
package main | ||
|
||
import "github.com/zMoooooritz/nachrichten/cmd" | ||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/zMoooooritz/nachrichten/cmd" | ||
) | ||
|
||
var ( | ||
// Set via ldflags when building | ||
Version = "" | ||
CommitSHA = "" | ||
|
||
configFile = flag.String("config", "", "Path to configuration file") | ||
logFile = flag.String("debug", "", "Path to log file") | ||
version = flag.Bool("version", false, "Display version") | ||
) | ||
|
||
func main() { | ||
cmd.Run() | ||
flag.Parse() | ||
|
||
if *version { | ||
if len(CommitSHA) > 7 { | ||
CommitSHA = CommitSHA[:7] | ||
} | ||
if Version == "" { | ||
Version = "(built from source)" | ||
} | ||
|
||
fmt.Printf("nachrichten %s", Version) | ||
if len(CommitSHA) > 0 { | ||
fmt.Printf(" (%s)", CommitSHA) | ||
} | ||
|
||
fmt.Println() | ||
os.Exit(0) | ||
} | ||
|
||
cmd.Run(*configFile, *logFile) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters