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