-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
It would be nice to add a version output.
The version seems to be passed in
hcl2json/.github/workflows/deploy.yml
Lines 47 to 58 in 75e097e
- name: Update environment | |
run: | | |
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
echo "TARGET_NAME=hcl2json_${{ matrix.os.name }}_${{ matrix.arch}}${{ matrix.os.ext }}" >> $GITHUB_ENV | |
- name: Build | |
run: 'go build -ldflags="-X main.Version=${{ env.VERSION }}"' | |
- name: Upload | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mv hcl2json${{ matrix.os.ext }} $TARGET_NAME | |
gh release upload v$VERSION $TARGET_NAME |
But not exposed as a flag
Lines 17 to 20 in 75e097e
var options convert.Options | |
flag.BoolVar(&options.Simplify, "simplify", false, "If true attempt to simply expressions which don't contain any variables or unknown functions") | |
flag.Parse() |
It could be as simple as this
import (
"bytes"
"encoding/json"
"flag"
+ "fmt"
"io"
"log"
"os"
"github.com/tmccombs/hcl2json/convert"
)
+var (
+ version = "dev"
+)
func main() {
logger := log.New(os.Stderr, "", 0)
var options convert.Options
flag.BoolVar(&options.Simplify, "simplify", false, "If true attempt to simply expressions which don't contain any variables or unknown functions")
+ flag.BoolVar(&options.Version, "version", false, "return version")
flag.Parse()
+ if options.Version {
+ fmt.Println(options.Version)
+ os.Exit(0)
+ }
Metadata
Metadata
Assignees
Labels
No labels