go-hep.org/x/hep@v0.38.1/fwk/cmd/fwk-app/main.go (about) 1 // Copyright ©2017 The go-hep Authors. 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 5 package main 6 7 import ( 8 "context" 9 "flag" 10 "os" 11 12 "codeberg.org/gonuts/commander" 13 ) 14 15 func handle_err(err error) { 16 if err != nil { 17 panic(err) 18 } 19 } 20 21 var ( 22 g_cmd *commander.Command 23 ) 24 25 func init() { 26 g_cmd = &commander.Command{ 27 UsageLine: "fwk-app <sub-command> [options] [args [...]]", 28 Short: "builds and runs fwk-based applications", 29 Subcommands: []*commander.Command{ 30 fwk_make_cmd_run(), 31 fwk_make_cmd_build(), 32 }, 33 Flag: *flag.NewFlagSet("fwk-app", flag.ExitOnError), 34 } 35 } 36 37 func main() { 38 39 var err error 40 41 err = g_cmd.Flag.Parse(os.Args[1:]) 42 handle_err(err) 43 44 args := g_cmd.Flag.Args() 45 err = g_cmd.Dispatch(context.Background(), args) 46 handle_err(err) 47 }