license: embed license in executable
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
7
cli.go
7
cli.go
@@ -25,10 +25,9 @@ func init() {
|
||||
}
|
||||
|
||||
func copyArgs() {
|
||||
if printVersion {
|
||||
fmt.Println(Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
tryLauncher()
|
||||
tryVersion()
|
||||
tryLicense()
|
||||
|
||||
command = flag.Args()
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
packages = [
|
||||
(buildGoModule rec {
|
||||
pname = "ego";
|
||||
version = "flake";
|
||||
version = "0.0.0-flake";
|
||||
|
||||
src = ./.;
|
||||
vendorHash = null; # we have no dependencies :3
|
||||
|
||||
26
license.go
Normal file
26
license.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed LICENSE
|
||||
license string
|
||||
|
||||
printLicense bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&printLicense, "license", false, "Print license")
|
||||
}
|
||||
|
||||
func tryLicense() {
|
||||
if printLicense {
|
||||
fmt.Println(license)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
8
main.go
8
main.go
@@ -16,6 +16,13 @@ import (
|
||||
|
||||
var Version = "impure"
|
||||
|
||||
func tryVersion() {
|
||||
if printVersion {
|
||||
fmt.Println(Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
ego *user.User
|
||||
uid int
|
||||
@@ -42,7 +49,6 @@ const (
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
tryLauncher()
|
||||
copyArgs()
|
||||
|
||||
if u, err := strconv.Atoi(ego.Uid); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user