Skip to content

Commit

Permalink
feat: Add --version support (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikew authored Oct 7, 2024
1 parent 4cae00c commit 5ca2a0a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/dist
/src/manifest.json
2 changes: 2 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"name": "nvrh",
"shortDescription": "A remote helper for neovim",
"version": "0.1.5"
}
2 changes: 2 additions & 0 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -ex
ARCHS=(amd64 arm64)
OSES=(linux darwin windows)

cp manifest.json src/

for os in "${OSES[@]}"; do
for arch in "${ARCHS[@]}"; do
GOOS="$os" GOARCH="$arch" go build -o "dist/$(basename "$PWD")-$os-$arch" ./src/main.go
Expand Down
23 changes: 21 additions & 2 deletions src/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
_ "embed"
"encoding/json"
"log"
"os"

Expand All @@ -9,10 +11,27 @@ import (
"nvrh/src/client"
)

//go:embed manifest.json
var manifestData []byte

type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
ShortDescription string `json:"shortDescription"`
}

func main() {
var manifest Manifest
if err := json.Unmarshal(manifestData, &manifest); err != nil {
log.Fatalf("Error reading manifest: %v", err)
}

app := &cli.App{
Name: "nvrh",
Usage: "Helps work with a remote nvim instance",
Name: manifest.Name,
// These fields are named kind of strange. The `Usage` field is paired with
// the `Name` when running `--help`.
Usage: manifest.ShortDescription,
Version: manifest.Version,

Commands: []*cli.Command{
&client.CliClientCommand,
Expand Down

0 comments on commit 5ca2a0a

Please sign in to comment.