Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add version information to fast-archiver help output

  • Loading branch information...
commit 5e286ce13ebd4486e0842ee9439965e92cf10f8a 1 parent 61648df
Mathieu Fenniak mfenniak authored
Showing with 28 additions and 2 deletions.
  1. +3 −2 README.rst
  2. +16 −0 build.sh
  3. +9 −0 main.go
5 README.rst
View
@@ -47,8 +47,9 @@ through ssh::
Build
-----
-fast-archiver is written in `Go`_, for Go version 1. To build it, run ``go
-build`` in the fast-archiver directory.
+fast-archiver is written in `Go`_, for Go version 1. fast-archiver uses the Go
+build system, but with a little shell script around it to enter the current git
+repo version numbers. To build, run the ``build.sh`` script.
.. _Go: http://golang.org/
16 build.sh
View
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+TAG=`git describe 2> /dev/null`
+REV=`git rev-parse --short HEAD 2> /dev/null`
+
+if [ -z "$TAG" ];
+then
+ TAG="-"
+fi
+if [ -z "$REV" ];
+then
+ REV="-"
+fi
+
+go build -ldflags "-X main.tag $TAG -X main.rev $REV"
+
9 main.go
View
@@ -3,6 +3,7 @@ package main
import (
"bufio"
"flag"
+ "fmt"
"log"
"math"
"os"
@@ -40,8 +41,16 @@ var verbose bool
var logger *log.Logger
var ignorePerms bool
var ignoreOwners bool
+var tag string
+var rev string
func main() {
+ flag.Usage = func() {
+ fmt.Fprintf(os.Stderr, "%s (tag: %s, rev: %s)\n", os.Args[0], tag, rev)
+ fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
+ flag.PrintDefaults()
+ }
+
extract := flag.Bool("x", false, "extract archive")
create := flag.Bool("c", false, "create archive")
inputFileName := flag.String("i", "", "input file for extraction; defaults to stdin (-x only)")
Please sign in to comment.
Something went wrong with that request. Please try again.