blob: 29b45c5edcb85186745ec2fca0b29009b7161d72 [file] [log] [blame]
Matteo Scandolo82c16d02019-09-24 09:34:32 -07001/*
2 * Portions copyright 2019-present Open Networking Foundation
3 * Original copyright 2019-present Ciena Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17package main
18
19import (
20 "fmt"
21 "github.com/jessevdk/go-flags"
22 "github.com/opencord/bbsim/internal/bbsimctl/commands"
23 "github.com/opencord/bbsim/internal/bbsimctl/config"
24 "os"
25 "path"
26)
27
28func main() {
29
30 parser := flags.NewNamedParser(path.Base(os.Args[0]),
31 flags.HelpFlag|flags.PassDoubleDash|flags.PassAfterNonOption)
32 _, err := parser.AddGroup("Global Options", "", &config.GlobalOptions)
33 if err != nil {
34 panic(err)
35 }
36
37 commands.RegisterConfigCommands(parser)
38 commands.RegisterOltCommands(parser)
39 commands.RegisterONUCommands(parser)
40
41 _, err = parser.ParseArgs(os.Args[1:])
42 if err != nil {
43 _, ok := err.(*flags.Error)
44 if ok {
45 real := err.(*flags.Error)
46 if real.Type == flags.ErrHelp {
47 os.Stdout.WriteString(err.Error() + "\n")
48 return
49 }
50 }
51
52 //corderror, ok := err.(corderrors.CordCtlError)
53 //if ok {
54 // if corderror.ShouldDumpStack() || config.GlobalOptions.Debug {
55 // os.Stderr.WriteString("\n" + corderror.Stack())
56 // }
57 //}
58
59 fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err.Error())
60
61 os.Exit(1)
62 }
63}