aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cli.go7
-rw-r--r--flake.nix2
-rw-r--r--license.go26
-rw-r--r--main.go8
4 files changed, 37 insertions, 6 deletions
diff --git a/cli.go b/cli.go
index 9a4d3a01..ca1b41b6 100644
--- a/cli.go
+++ b/cli.go
@@ -25,10 +25,9 @@ func init() {
}
func copyArgs() {
- if printVersion {
- fmt.Println(Version)
- os.Exit(0)
- }
+ tryLauncher()
+ tryVersion()
+ tryLicense()
command = flag.Args()
diff --git a/flake.nix b/flake.nix
index 48cb435d..8c8e4193 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,7 +31,7 @@
packages = [
(buildGoModule rec {
pname = "ego";
- version = "flake";
+ version = "0.0.0-flake";
src = ./.;
vendorHash = null; # we have no dependencies :3
diff --git a/license.go b/license.go
new file mode 100644
index 00000000..4cbe0128
--- /dev/null
+++ b/license.go
@@ -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)
+ }
+}
diff --git a/main.go b/main.go
index ed5566eb..4a719d85 100644
--- a/main.go
+++ b/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 {