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) |
Scott Baker | 5281d00 | 2019-05-16 10:45:26 -0700 | [diff] [blame^] | 35 | commands.RegisterModelTypeCommands(parser) |
Scott Baker | 2c0ebda | 2019-05-06 16:55:47 -0700 | [diff] [blame] | 36 | commands.RegisterServiceCommands(parser) |
| 37 | commands.RegisterTransferCommands(parser) |
| 38 | commands.RegisterVersionCommands(parser) |
Scott Baker | 63ce82e | 2019-05-15 09:01:42 -0700 | [diff] [blame] | 39 | commands.RegisterCompletionCommands(parser) |
| 40 | commands.RegisterConfigCommands(parser) |
Scott Baker | 2c0ebda | 2019-05-06 16:55:47 -0700 | [diff] [blame] | 41 | |
| 42 | _, err = parser.ParseArgs(os.Args[1:]) |
| 43 | if err != nil { |
| 44 | _, ok := err.(*flags.Error) |
| 45 | if ok { |
| 46 | real := err.(*flags.Error) |
| 47 | if real.Type == flags.ErrHelp { |
| 48 | return |
| 49 | } |
| 50 | } else { |
| 51 | panic(err) |
| 52 | } |
| 53 | os.Exit(1) |
| 54 | } |
| 55 | } |