bldy.build/build@v0.0.0-20181002085557-d04b29acc6a7/cmd/bldy/main.go (about) 1 // Copyright 2018 Sevki <s@sevki.org>. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 package main // import "bldy.build/build/cmd/bldy" 5 import ( 6 "context" 7 "flag" 8 "os" 9 10 "bldy.build/build/cmd/build" 11 "bldy.build/build/cmd/query" 12 "bldy.build/build/label" 13 "github.com/google/subcommands" 14 ) 15 16 func main() { 17 subcommands.Register(subcommands.HelpCommand(), "") 18 subcommands.Register(subcommands.FlagsCommand(), "") 19 subcommands.Register(subcommands.CommandsCommand(), "") 20 subcommands.Register(&build.BuildCmd{}, "") 21 subcommands.Register(&query.QueryCmd{}, "") 22 subcommands.Register(&query.HashCmd{}, "") 23 24 flag.Parse() 25 ctx := context.Background() 26 if l, err := label.Parse(flag.Arg(1)); err == nil { 27 os.Exit(int(subcommands.Execute(ctx, l))) 28 } else { 29 os.Exit(int(subcommands.Execute(ctx))) 30 } 31 }