Skip to content

Commit 882bd36

Browse files
committed
Fix #5: Expose version.
1 parent 2dcded8 commit 882bd36

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

main.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"log"
56
"io"
67
"io/ioutil"
@@ -14,6 +15,8 @@ import (
1415
"github.com/mitchellh/go-homedir"
1516
)
1617

18+
const Version = "0.0.1"
19+
1720
func selfDigest() (string, error) {
1821
var result []byte
1922
fileName, err := osext.Executable()
@@ -82,6 +85,13 @@ func deployRuntime() (string, error) {
8285
}
8386

8487
func main() {
88+
// We exclude the first argument since it's just the current process path.
89+
args := os.Args[1:]
90+
if len(args) == 1 && (args[0] == "-v" || args[0] == "--version") {
91+
fmt.Println("runx", Version)
92+
return
93+
}
94+
8595
dir, err := deployRuntime()
8696
if err != nil {
8797
log.Fatal(err)
@@ -90,10 +100,7 @@ func main() {
90100

91101
ruby := setupRuntime(dir)
92102
script := path.Join(dir, "runtime", "lib", "app", "runx.rb")
93-
94-
// We want to run "ruby runx.rb [args...]".
95-
// We exclude the first argument to this process since it's just self.
96-
args := append([]string{script}, os.Args[1:]...)
103+
args = append([]string{script}, args...)
97104

98105
var cmd *exec.Cmd
99106

runx.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def find_runfile
5252
runfile_dir = File.dirname(runfile)
5353
Dir.chdir(runfile_dir) do
5454
manager = TaskManager.new
55-
manager.instance_eval File.read(runfile), runfile
55+
manager.instance_eval(File.read(runfile), runfile)
5656

5757
task_name = ARGV[0]
5858
if !task_name

0 commit comments

Comments
 (0)