-
-
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.
- Loading branch information
1 parent
340d559
commit dece13a
Showing
4 changed files
with
57 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,6 @@ builds: | |
- darwin_amd64 | ||
- darwin_arm64 | ||
- windows_amd64 | ||
ldflags: | ||
- -s -w | ||
|
||
archives: | ||
- format: tar.gz | ||
|
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log/slog" | ||
"os" | ||
) | ||
|
||
var version string | ||
|
||
func printVersion() { | ||
if version == "" { | ||
version = "development" | ||
} | ||
|
||
println("amock version " + version) | ||
} | ||
|
||
var DebugValue = false | ||
|
||
var versionFlag = flag.Bool("version", false, "Print the current version and exit") | ||
var helpFlag = flag.Bool("help", false, "Print help message and exit") | ||
var debugFlag = flag.Bool("debug", false, "Enable debug logging") | ||
|
||
func parseFlags() { | ||
flag.BoolVar(versionFlag, "v", false, "Print the current version and exit") | ||
flag.BoolVar(debugFlag, "d", false, "Enable debug logging") | ||
flag.BoolVar(helpFlag, "h", false, "Print help message and exit") | ||
DebugValue = *debugFlag | ||
|
||
flag.Parse() | ||
|
||
if *versionFlag { | ||
printVersion() | ||
os.Exit(0) | ||
} | ||
|
||
if *helpFlag || len(flag.Args()) >= 0 && flag.Arg(0) == "help" { | ||
println("Usage:\n\tamock [host:port] [flags]") | ||
println("\n[host:port] - (optional) The host and port to bind the server to") | ||
println("\nFlags: (optional)") | ||
flag.PrintDefaults() | ||
os.Exit(0) | ||
} | ||
|
||
if DebugValue { | ||
LogLevel.Set(slog.LevelDebug) | ||
slog.SetLogLoggerLevel(LogLevel.Level()) | ||
} | ||
} |
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