Includes mmctl into the mono-repo (#23091)
* Includes mmctl into the mono-repo * Update to use the new public module paths * Adds docs check to the mmctl CI * Fix public utils import path * Tidy up modules * Fix linter * Update CI tasks to use the new file structure * Update CI references
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
412109b02e
Коммит
951456c780
48
server/cmd/mmctl/commands/docs.go
Обычный файл
48
server/cmd/mmctl/commands/docs.go
Обычный файл
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
)
|
||||
|
||||
var DocsCmd = &cobra.Command{
|
||||
Use: "docs",
|
||||
Short: "Generates mmctl documentation",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: docsCmdF,
|
||||
}
|
||||
|
||||
func init() {
|
||||
DocsCmd.Flags().StringP("directory", "d", "docs", "The directory where the docs would be generated in.")
|
||||
|
||||
RootCmd.AddCommand(DocsCmd)
|
||||
}
|
||||
|
||||
func docsCmdF(cmd *cobra.Command, args []string) error {
|
||||
outDir, _ := cmd.Flags().GetString("directory")
|
||||
fileInfo, err := os.Stat(outDir)
|
||||
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
if createErr := os.Mkdir(outDir, 0755); createErr != nil {
|
||||
return createErr
|
||||
}
|
||||
} else if !fileInfo.IsDir() {
|
||||
return fmt.Errorf(fmt.Sprintf("File \"%s\" is not a directory", outDir))
|
||||
}
|
||||
|
||||
err = doc.GenReSTTree(RootCmd, outDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Ссылка в новой задаче
Block a user