2 Copyright © 2019 NAME HERE <EMAIL ADDRESS>
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
22 "github.com/spf13/cobra"
24 homedir "github.com/mitchellh/go-homedir"
25 "github.com/spf13/viper"
33 elcliLongDescription = `
34 +----------------------------------------------------------+
36 | Command Line Interface to Bootsrap ELIOT Cluster |
37 +----------------------------------------------------------+
39 ELCLI Command is use to setup the ELIOT Cluster.
40 It installs the ELIOT Manager and the ELIOT Nodes.
41 ELIOT Manager is the core-controller and the ELIOT Nodes are
42 the edge nodes which acts as IOT Gateway or uCPE, where the
43 application PODS will be running.
46 +-----------------------------------------------------------+
47 |To setup up the ELIOT Cluster the elcli init command has to|
48 |be executed in the ELIOT Manager Node. |
53 +-----------------------------------------------------------+
59 // rootCmd represents the base command when called without any subcommands
60 var rootCmd = &cobra.Command{
62 Short: "elcli : Bootstarp ELIOT Cluster",
63 Long: elcliLongDescription,
64 Example: elcliExample,
67 // Execute adds all child commands to the root command and sets flags appropriately.
68 // This is called by main.main(). It only needs to happen once to the rootCmd.
70 if err := rootCmd.Execute(); err != nil {
77 cobra.OnInitialize(initConfig)
82 // initConfig reads in config file and ENV variables if set.
85 // Use config file from the flag.
86 viper.SetConfigFile(cfgFile)
88 // Find home directory.
89 home, err := homedir.Dir()
95 // Search config in home directory with name ".elcli" (without extension).
96 viper.AddConfigPath(home)
97 viper.SetConfigName(".elcli")
100 viper.AutomaticEnv() // read in environment variables that match
102 // If a config file is found, read it in.
103 if err := viper.ReadInConfig(); err == nil {
104 fmt.Println("Using config file:", viper.ConfigFileUsed())