gitee.com/mirrors/Hugo-Go@v0.47.1/commands/env.go (about)

     1  // Copyright 2016 The Hugo Authors. All rights reserved.
     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  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package commands
    15  
    16  import (
    17  	"runtime"
    18  
    19  	"github.com/spf13/cobra"
    20  	jww "github.com/spf13/jwalterweatherman"
    21  )
    22  
    23  var _ cmder = (*envCmd)(nil)
    24  
    25  type envCmd struct {
    26  	*baseCmd
    27  }
    28  
    29  func newEnvCmd() *envCmd {
    30  	return &envCmd{baseCmd: newBaseCmd(&cobra.Command{
    31  		Use:   "env",
    32  		Short: "Print Hugo version and environment info",
    33  		Long:  `Print Hugo version and environment info. This is useful in Hugo bug reports.`,
    34  		RunE: func(cmd *cobra.Command, args []string) error {
    35  			printHugoVersion()
    36  			jww.FEEDBACK.Printf("GOOS=%q\n", runtime.GOOS)
    37  			jww.FEEDBACK.Printf("GOARCH=%q\n", runtime.GOARCH)
    38  			jww.FEEDBACK.Printf("GOVERSION=%q\n", runtime.Version())
    39  
    40  			return nil
    41  		},
    42  	}),
    43  	}
    44  }