/
flags.go
92 lines (71 loc) · 4.27 KB
/
flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// SPDX-FileCopyrightText: 2020 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package app
import (
"os"
"path/filepath"
"github.com/spf13/cobra"
)
func configureFlags(command *cobra.Command) {
command.Flags().StringP("destination", "d", "",
"Destination path.")
_ = vip.BindPFlag("destination", command.Flags().Lookup("destination"))
command.Flags().StringP("manifest", "f", "",
"Manifest path.")
_ = vip.BindPFlag("manifest", command.Flags().Lookup("manifest"))
command.Flags().String("resources-download-path", "__resources",
"Resources download path.")
_ = vip.BindPFlag("resources-download-path", command.Flags().Lookup("resources-download-path"))
command.Flags().StringToString("github-oauth-token-map", map[string]string{},
"GitHub personal tokens authorizing read access from repositories per GitHub instance. Note that if the GitHub token is already provided by `github-oauth-token` it will be overridden by it.")
_ = vip.BindPFlag("github-oauth-token-map", command.Flags().Lookup("github-oauth-token-map"))
command.Flags().String("github-info-destination", "",
"If specified, docforge will download also additional github info for the files from the documentation structure into this destination.")
_ = vip.BindPFlag("github-info-destination", command.Flags().Lookup("github-info-destination"))
command.Flags().Bool("fail-fast", false,
"Fail-fast vs fault tolerant operation.")
_ = vip.BindPFlag("fail-fast", command.Flags().Lookup("fail-fast"))
command.Flags().Bool("dry-run", false,
"Runs the command end-to-end but instead of writing files, it will output the projected file/folder hierarchy to the standard output and statistics for the processing of each file.")
_ = vip.BindPFlag("dry-run", command.Flags().Lookup("dry-run"))
command.Flags().Bool("resolve", false,
"Resolves the documentation structure and prints it to the standard output. The resolution expands nodeSelector constructs into node hierarchies.")
_ = vip.BindPFlag("resolve", command.Flags().Lookup("resolve"))
command.Flags().Int("document-workers", 25,
"Number of parallel workers for document processing.")
_ = vip.BindPFlag("document-workers", command.Flags().Lookup("document-workers"))
command.Flags().Int("validation-workers", 10,
"Number of parallel workers to validate the markdown links")
_ = vip.BindPFlag("validation-workers", command.Flags().Lookup("validation-workers"))
command.Flags().Int("download-workers", 10,
"Number of workers downloading document resources in parallel.")
_ = vip.BindPFlag("download-workers", command.Flags().Lookup("download-workers"))
command.Flags().Bool("hugo", false,
"Build documentation bundle for hugo.")
_ = vip.BindPFlag("hugo", command.Flags().Lookup("hugo"))
command.Flags().Bool("hugo-pretty-urls", true,
"Build documentation bundle for hugo with pretty URLs (./sample.md -> ../sample). Only useful with --hugo=true")
_ = vip.BindPFlag("hugo-pretty-urls", command.Flags().Lookup("hugo-pretty-urls"))
command.Flags().String("hugo-base-url", "",
"Rewrites the relative links of documentation files to root-relative where possible.")
_ = vip.BindPFlag("hugo-base-url", command.Flags().Lookup("hugo-base-url"))
command.Flags().StringSlice("hugo-section-files", []string{"readme.md", "readme", "read.me", "index.md", "index"},
"When building a Hugo-compliant documentation bundle, files with filename matching one form this list (in that order) will be renamed to _index.md. Only useful with --hugo=true")
_ = vip.BindPFlag("hugo-section-files", command.Flags().Lookup("hugo-section-files"))
command.Flags().StringSlice("extracted-files-formats", []string{".md"},
"Supported content format extensions (exampel: .md)")
_ = vip.BindPFlag("extracted-files-formats", command.Flags().Lookup("extracted-files-formats"))
command.Flags().Bool("validate-links", true,
"Links should be validated")
_ = vip.BindPFlag("validate-links", command.Flags().Lookup("validate-links"))
cacheDir := ""
userHomeDir, err := os.UserHomeDir()
if err == nil {
// default value $HOME/.docforge
cacheDir = filepath.Join(userHomeDir, DocforgeHomeDir)
}
command.Flags().String("cache-dir", cacheDir,
"Cache directory, used for repository cache.")
_ = vip.BindPFlag("cache-dir", command.Flags().Lookup("cache-dir"))
}