gitee.com/mirrors/gauge@v1.0.6/cmd/docs.go (about)

     1  // Copyright 2015 ThoughtWorks, Inc.
     2  
     3  // This file is part of Gauge.
     4  
     5  // Gauge is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  
    10  // Gauge is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU General Public License for more details.
    14  
    15  // You should have received a copy of the GNU General Public License
    16  // along with Gauge.  If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package cmd
    19  
    20  import (
    21  	"fmt"
    22  
    23  	"github.com/getgauge/gauge/api"
    24  	"github.com/getgauge/gauge/config"
    25  	"github.com/getgauge/gauge/plugin"
    26  	"github.com/spf13/cobra"
    27  )
    28  
    29  var docsCmd = &cobra.Command{
    30  	Use:     "docs [flags] <plugin> [args]",
    31  	Short:   "Generate documentation using specified plugin",
    32  	Long:    `Generate documentation using specified plugin.`,
    33  	Example: "  gauge docs spectacle specs/",
    34  	Run: func(cmd *cobra.Command, args []string) {
    35  		loadEnvAndReinitLogger(cmd)
    36  		if err := config.SetProjectRoot(args); err != nil {
    37  			exit(err, cmd.UsageString())
    38  		}
    39  		if len(args) < 1 {
    40  			exit(fmt.Errorf("Missing argument <plugin name>."), cmd.UsageString())
    41  		}
    42  		specDirs := getSpecsDir(args[1:])
    43  		gaugeConnectionHandler := api.Start(specDirs)
    44  		plugin.GenerateDoc(args[0], specDirs, gaugeConnectionHandler.ConnectionPortNumber())
    45  	},
    46  	DisableAutoGenTag: true,
    47  }
    48  
    49  func init() {
    50  	GaugeCmd.AddCommand(docsCmd)
    51  }