blob: 293c164e9dc90769c361d17f2def0ba5b400ff32 [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"
Anand S Katti86552f92020-03-03 21:56:32 +053021 "os"
22 "path"
23
Matteo Scandolo82c16d02019-09-24 09:34:32 -070024 "github.com/jessevdk/go-flags"
25 "github.com/opencord/bbsim/internal/bbsimctl/commands"
26 "github.com/opencord/bbsim/internal/bbsimctl/config"
Matteo Scandolo82c16d02019-09-24 09:34:32 -070027)
28
29func main() {
30
31 parser := flags.NewNamedParser(path.Base(os.Args[0]),
32 flags.HelpFlag|flags.PassDoubleDash|flags.PassAfterNonOption)
33 _, err := parser.AddGroup("Global Options", "", &config.GlobalOptions)
34 if err != nil {
35 panic(err)
36 }
37
38 commands.RegisterConfigCommands(parser)
39 commands.RegisterOltCommands(parser)
40 commands.RegisterONUCommands(parser)
Matteo Scandolo4a036262020-08-17 15:56:13 -070041 commands.RegisterServiceCommands(parser)
Pragya Aryabd731ec2020-02-11 16:38:17 +053042 commands.RegisterPonCommands(parser)
Matteo Scandoloa42dd352019-09-30 15:46:43 -070043 commands.RegisterCompletionCommands(parser)
Matteo Scandolo2bf742a2019-10-01 11:33:34 -070044 commands.RegisterLoggingCommands(parser)
hkouser24361d42020-12-14 19:21:47 +053045 commands.RegisterDMICommands(parser)
Matteo Scandolo82c16d02019-09-24 09:34:32 -070046
47 _, err = parser.ParseArgs(os.Args[1:])
48 if err != nil {
49 _, ok := err.(*flags.Error)
50 if ok {
51 real := err.(*flags.Error)
52 if real.Type == flags.ErrHelp {
53 os.Stdout.WriteString(err.Error() + "\n")
54 return
55 }
56 }
57
Matteo Scandolo82c16d02019-09-24 09:34:32 -070058 fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err.Error())
59
60 os.Exit(1)
61 }
62}