...

Source file src/github.com/sigstore/cosign/v2/cmd/help/main.go

Documentation: github.com/sigstore/cosign/v2/cmd/help

     1  // Copyright 2021 The Sigstore Authors.
     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  
    15  package main
    16  
    17  import (
    18  	"fmt"
    19  	"os"
    20  
    21  	"github.com/sigstore/cosign/v2/cmd/cosign/cli"
    22  	"github.com/sigstore/cosign/v2/cmd/cosign/cli/templates"
    23  	errors "github.com/sigstore/cosign/v2/cmd/cosign/errors"
    24  	"github.com/spf13/cobra"
    25  	"github.com/spf13/cobra/doc"
    26  )
    27  
    28  func main() {
    29  	var dir string
    30  	root := &cobra.Command{
    31  		Use:          "gendoc",
    32  		Short:        "Generate cosign's help docs",
    33  		SilenceUsage: true,
    34  		Args:         cobra.NoArgs,
    35  		RunE: func(*cobra.Command, []string) error {
    36  			err := errors.GenerateExitCodeDocs(dir)
    37  			if err != nil {
    38  				fmt.Println(err)
    39  				os.Exit(1)
    40  			}
    41  			return doc.GenMarkdownTree(cli.New(), dir)
    42  		},
    43  	}
    44  	root.Flags().StringVarP(&dir, "dir", "d", "doc", "Path to directory in which to generate docs")
    45  
    46  	templates.SetCustomUsageFunc(root)
    47  
    48  	if err := root.Execute(); err != nil {
    49  		fmt.Println(err)
    50  		os.Exit(1)
    51  	}
    52  }
    53  

View as plain text