github.com/annchain/OG@v0.0.9/client/cmd/info.go (about)

     1  // Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  package cmd
    15  
    16  import (
    17  	"bytes"
    18  	"encoding/json"
    19  	"fmt"
    20  	"github.com/annchain/OG/arefactor/common/httplib"
    21  	"github.com/spf13/cobra"
    22  )
    23  
    24  var (
    25  	InfoCmd = &cobra.Command{
    26  		Use:   "info",
    27  		Short: "get chorus info",
    28  		Run:   status,
    29  	}
    30  	netInfoCmd = &cobra.Command{
    31  		Use:   "net",
    32  		Short: "net_info",
    33  		Run:   netInfo,
    34  	}
    35  )
    36  
    37  func status(cmd *cobra.Command, args []string) {
    38  	requesrUrl := Host + "/status"
    39  	req := httplib.Get(requesrUrl)
    40  	data, err := req.Bytes()
    41  	if err != nil {
    42  		fmt.Println(err)
    43  		return
    44  	}
    45  	var out bytes.Buffer
    46  	json.Indent(&out, data, "", "\t")
    47  	fmt.Println(out.String())
    48  }
    49  
    50  func netInfo(cmd *cobra.Command, args []string) {
    51  
    52  }