Scott Baker | 2c0ebda | 2019-05-06 16:55:47 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 20 | flags "github.com/jessevdk/go-flags" |
| 21 | "github.com/opencord/cordctl/commands" |
| 22 | "os" |
| 23 | "path" |
| 24 | ) |
| 25 | |
| 26 | func main() { |
| 27 | |
| 28 | parser := flags.NewNamedParser(path.Base(os.Args[0]), flags.Default|flags.PassAfterNonOption) |
| 29 | _, err := parser.AddGroup("Global Options", "", &commands.GlobalOptions) |
| 30 | if err != nil { |
| 31 | panic(err) |
| 32 | } |
Scott Baker | 6cf525a | 2019-05-09 12:25:08 -0700 | [diff] [blame] | 33 | commands.RegisterBackupCommands(parser) |
Scott Baker | 2c0ebda | 2019-05-06 16:55:47 -0700 | [diff] [blame] | 34 | commands.RegisterModelCommands(parser) |
| 35 | commands.RegisterServiceCommands(parser) |
| 36 | commands.RegisterTransferCommands(parser) |
| 37 | commands.RegisterVersionCommands(parser) |
Scott Baker | 63ce82e | 2019-05-15 09:01:42 -0700 | [diff] [blame^] | 38 | commands.RegisterCompletionCommands(parser) |
| 39 | commands.RegisterConfigCommands(parser) |
Scott Baker | 2c0ebda | 2019-05-06 16:55:47 -0700 | [diff] [blame] | 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 | return |
| 48 | } |
| 49 | } else { |
| 50 | panic(err) |
| 51 | } |
| 52 | os.Exit(1) |
| 53 | } |
| 54 | } |