blob: f5ede01b4cb151087da1ba3e5d94db84d66eaf2a [file] [log] [blame]
Scott Baker63ce82e2019-05-15 09:01:42 -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 commands
18
19import (
20 "fmt"
21 flags "github.com/jessevdk/go-flags"
Scott Bakerce11c492019-07-30 15:53:34 -070022 "github.com/opencord/cordctl/internal/pkg/config"
Scott Baker63ce82e2019-05-15 09:01:42 -070023 "gopkg.in/yaml.v2"
24)
25
26const copyrightNotice = `
27# Portions copyright 2019-present Open Networking Foundation
28# Original copyright 2019-present Ciena Corporation
29#
30# Licensed under the Apache License, Version 2.0 (the "License");
31# you may not use this file except in compliance with the License.
32# You may obtain a copy of the License at
33#
34# http://www.apache.org/licenses/LICENSE-2.0
35#
36# Unless required by applicable law or agreed to in writing, software
37# distributed under the License is distributed on an "AS IS" BASIS,
38# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39# See the License for the specific language governing permissions and
40# limitations under the License.
41#
42`
43
44type ConfigOptions struct {
45}
46
47func RegisterConfigCommands(parent *flags.Parser) {
48 parent.AddCommand("config", "generate cordctl configuration", "Commands to generate cordctl configuration", &ConfigOptions{})
49}
50
51func (options *ConfigOptions) Execute(args []string) error {
52 //GlobalConfig
Scott Bakerce11c492019-07-30 15:53:34 -070053 config.ProcessGlobalOptions()
54 b, err := yaml.Marshal(config.GlobalConfig)
Scott Baker63ce82e2019-05-15 09:01:42 -070055 if err != nil {
56 return err
57 }
58 fmt.Println(copyrightNotice)
59 fmt.Println(string(b))
60 return nil
61}