blob: 76481820c6b49d21f5a9b329c016bc11ea32714a [file] [log] [blame]
Scott Baker2c0ebda2019-05-06 16:55:47 -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 flags "github.com/jessevdk/go-flags"
21 "github.com/opencord/cordctl/commands"
22 "os"
23 "path"
24)
25
26func 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 }
33 commands.RegisterModelCommands(parser)
34 commands.RegisterServiceCommands(parser)
35 commands.RegisterTransferCommands(parser)
36 commands.RegisterVersionCommands(parser)
37
38 _, err = parser.ParseArgs(os.Args[1:])
39 if err != nil {
40 _, ok := err.(*flags.Error)
41 if ok {
42 real := err.(*flags.Error)
43 if real.Type == flags.ErrHelp {
44 return
45 }
46 } else {
47 panic(err)
48 }
49 os.Exit(1)
50 }
51}