Add usage message to androidmk
Test: androidmk 2>&1 | grep usage && androidmk --help 2>&1 | grep usage && echo ok Bug: 67426255 Change-Id: I1e5033321c62c6744672f2ea435a422a4b9bd3da
This commit is contained in:
parent
c21d11850d
commit
4b9ef72fe2
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -15,6 +16,13 @@ import (
|
|||
bpparser "github.com/google/blueprint/parser"
|
||||
)
|
||||
|
||||
var usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "usage: androidmk [flags] <inputFile>\n"+
|
||||
"\nandroidmk parses <inputFile> as an Android.mk file and attempts to output an analogous Android.bp file (to standard out)\n")
|
||||
flag.PrintDefaults()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// TODO: non-expanded variables with expressions
|
||||
|
||||
type bpFile struct {
|
||||
|
@ -85,7 +93,13 @@ type conditional struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
b, err := ioutil.ReadFile(os.Args[1])
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
if len(flag.Args()) != 1 {
|
||||
usage()
|
||||
}
|
||||
filePathToRead := flag.Arg(0)
|
||||
b, err := ioutil.ReadFile(filePathToRead)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue