File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ VERSION=` git describe --tags`
4+ CURRENT=` pwd`
5+ BASENAME=` basename " $CURRENT " `
6+ MAIN=cmd/${BASENAME} /main.go
7+ DATE=` date --rfc-3339=seconds | sed ' s/ /T/' `
8+ LDFLAGS=" -X main.Version=${VERSION} -X main.BuildTime=${DATE} "
9+
10+ go build -ldflags " ${LDFLAGS} " -o ${BASENAME} ${MAIN}
Original file line number Diff line number Diff line change @@ -13,7 +13,12 @@ import (
1313 "github.com/urfave/cli"
1414)
1515
16- var version = "0.1.0-dev"
16+ var (
17+ // Version is set by build.sh ldflags
18+ Version string
19+ // BuildTime is set by build.sh ldflags
20+ BuildTime string
21+ )
1722
1823const usage = "work with HTTP Archive (.har) files"
1924
@@ -27,8 +32,8 @@ func main() {
2732
2833 app := cli .NewApp ()
2934 app .Name = "hargo"
30- app .Version = version
31- app .Compiled = time .Now ( )
35+ app .Version = Version + " (" + BuildTime + ")"
36+ app .Compiled , _ = time .Parse ( time . RFC3339 , BuildTime )
3237 app .Authors = []cli.Author {
3338 {
3439 Name : "Mark A. Richman" ,
@@ -47,7 +52,6 @@ func main() {
4752 Usage : "Show debug output" },
4853 }
4954
50-
5155 app .Commands = []cli.Command {
5256 {
5357 Name : "fetch" ,
@@ -82,7 +86,12 @@ func main() {
8286 file , err := os .Open (harFile )
8387 if err == nil {
8488 r := newReader (file )
85- cmd , _ := hargo .ToCurl (r )
89+ cmd , err := hargo .ToCurl (r )
90+
91+ if err != nil {
92+ log .Error (err )
93+ }
94+
8695 fmt .Println (cmd )
8796 } else {
8897 log .Fatal ("Cannot open file: " , harFile )
You can’t perform that action at this time.
0 commit comments