env.go - hugo - [fork] hugo port for 9front
HTML git clone https://git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
env.go (2254B)
---
1 // Copyright 2024 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 "context"
18 "runtime"
19
20 "github.com/bep/simplecobra"
21 "github.com/gohugoio/hugo/common/hugo"
22 "github.com/spf13/cobra"
23 )
24
25 func newEnvCommand() simplecobra.Commander {
26 return &simpleCommand{
27 name: "env",
28 short: "Display version and environment info",
29 long: "Display version and environment info. This is useful in Hugo bug reports",
30 run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
31 r.Printf("%s\n", hugo.BuildVersionString())
32 r.Printf("GOOS=%q\n", runtime.GOOS)
33 r.Printf("GOARCH=%q\n", runtime.GOARCH)
34 r.Printf("GOVERSION=%q\n", runtime.Version())
35
36 if r.isVerbose() {
37 deps := hugo.GetDependencyList()
38 for _, dep := range deps {
39 r.Printf("%s\n", dep)
40 }
41 } else {
42 // These are also included in the GetDependencyList above;
43 // always print these as these are most likely the most useful to know about.
44 deps := hugo.GetDependencyListNonGo()
45 for _, dep := range deps {
46 r.Printf("%s\n", dep)
47 }
48 }
49 return nil
50 },
51 withc: func(cmd *cobra.Command, r *rootCommand) {
52 cmd.ValidArgsFunction = cobra.NoFileCompletions
53 },
54 }
55 }
56
57 func newVersionCmd() simplecobra.Commander {
58 return &simpleCommand{
59 name: "version",
60 run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
61 r.Println(hugo.BuildVersionString())
62 return nil
63 },
64 short: "Display version",
65 long: "Display version and environment info. This is useful in Hugo bug reports.",
66 withc: func(cmd *cobra.Command, r *rootCommand) {
67 cmd.ValidArgsFunction = cobra.NoFileCompletions
68 },
69 }
70 }