blob: b05bb5bcb1444c5db45452312fe7116f2b622709 [file] [log] [blame]
Matteo Scandolo8df63df2019-09-12 10: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 */
17
18package commands
19
20import (
21 "fmt"
22 "github.com/jessevdk/go-flags"
23 "github.com/opencord/bbsim/internal/bbsimctl/config"
24 "gopkg.in/yaml.v2"
25)
26
27const copyrightNotice = `
28# Portions copyright 2019-present Open Networking Foundation
29# Original copyright 2019-present Ciena Corporation
30#
31# Licensed under the Apache License, Version 2.0 (the "License");
32# you may not use this file except in compliance with the License.
33# You may obtain a copy of the License at
34#
35# http://www.apache.org/licenses/LICENSE-2.0
36#
37# Unless required by applicable law or agreed to in writing, software
38# distributed under the License is distributed on an "AS IS" BASIS,
39# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40# See the License for the specific language governing permissions and
41# limitations under the License.
42#
43`
44
45type ConfigOptions struct{}
46
47func RegisterConfigCommands(parent *flags.Parser) {
48 parent.AddCommand("config", "generate bbsimctl configuration", "Commands to generate bbsimctl configuration", &ConfigOptions{})
49}
50
51func (options *ConfigOptions) Execute(args []string) error {
52 //GlobalConfig
53 config.ProcessGlobalOptions()
54
55 b, err := yaml.Marshal(config.GlobalConfig)
56 if err != nil {
57 return err
58 }
59 fmt.Println(copyrightNotice)
60 fmt.Println(string(b))
61
62 fmt.Println("BBSimCtl details:")
63 fmt.Printf("\tVersion: %s \n", config.Version)
64 fmt.Printf("\tBuildTime: %s \n", config.BuildTime)
65 fmt.Printf("\tCommitHash: %s \n", config.CommitHash)
66 fmt.Printf("\tGitStatus: %s \n", config.GitStatus)
67 return nil
68}