Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 1 | /* |
Joey Armstrong | 4d6878e | 2024-02-08 16:29:26 -0500 | [diff] [blame] | 2 | * Portions Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 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 | */ |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 20 | "fmt" |
Anand S Katti | 86552f9 | 2020-03-03 21:56:32 +0530 | [diff] [blame] | 21 | "os" |
| 22 | "path" |
| 23 | |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 24 | "github.com/jessevdk/go-flags" |
| 25 | "github.com/opencord/bbsim/internal/bbsimctl/commands" |
| 26 | "github.com/opencord/bbsim/internal/bbsimctl/config" |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 27 | ) |
| 28 | |
| 29 | func 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) |
Nitin Subramanian | b0a333a | 2021-07-08 15:01:41 -0700 | [diff] [blame] | 41 | commands.RegisterUNICommands(parser) |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 42 | commands.RegisterServiceCommands(parser) |
Pragya Arya | bd731ec | 2020-02-11 16:38:17 +0530 | [diff] [blame] | 43 | commands.RegisterPonCommands(parser) |
Matteo Scandolo | a42dd35 | 2019-09-30 15:46:43 -0700 | [diff] [blame] | 44 | commands.RegisterCompletionCommands(parser) |
Matteo Scandolo | 2bf742a | 2019-10-01 11:33:34 -0700 | [diff] [blame] | 45 | commands.RegisterLoggingCommands(parser) |
hkouser | 24361d4 | 2020-12-14 19:21:47 +0530 | [diff] [blame] | 46 | commands.RegisterDMICommands(parser) |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 47 | |
| 48 | _, err = parser.ParseArgs(os.Args[1:]) |
| 49 | if err != nil { |
| 50 | _, ok := err.(*flags.Error) |
| 51 | if ok { |
| 52 | real := err.(*flags.Error) |
| 53 | if real.Type == flags.ErrHelp { |
| 54 | os.Stdout.WriteString(err.Error() + "\n") |
| 55 | return |
| 56 | } |
| 57 | } |
| 58 | |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 59 | fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err.Error()) |
| 60 | |
| 61 | os.Exit(1) |
| 62 | } |
| 63 | } |
Joey Armstrong | a7ef8d2 | 2023-12-11 18:11:53 -0500 | [diff] [blame] | 64 | |
| 65 | // [EOF] |