# README
Godoc Readme CLI
Generate README.md file for your go project using comments you already write
Usage: godoc-readme [flags]
Flags: -c, --confirm Use this flag to confirm overwriting existing README.md files. The default behaviour is to overwrite the file without confirmation. Confirmation also gives you the option to view the diff between the existing and generated file before overwriting it. -h, --help help for godoc-readme -p, --package string Specify the pattern for matching packages to generate the README.md files for. Default '' will match current package only -r, --recursive If set, recursively search for go packages in the directory and generate a README.md for each package; Default will only create a Readme for the package found in the current directory --skip-all Skips generating all sections besides the package documentation --skip-consts Shows generating the consts section --skip-empty Skips generating any type, func, var, const, or method that does not have a doc string --skip-examples Skips generating the examples section --skip-filenames Skips generating the files section --skip-funcs Skips generating the functions section --skip-imports Skips generating the imports section --skip-types Skips generating the types section --skip-vars Skips generating the vars section
Functions
func Execute
func Execute(args ...string) error
Execute runs the root command using the os.Args by default Optionally, you can pass in a list of arguments to run the command with
func init
func init()
Initializes the CLI flags/Arguments
Vars
var confirm_updates bool
var env string
[!NOTE] These Flags are used to determine which sections of the README.md file to generate
var flags template_functions.Flags = template_functions.Flags{}
var package_root string
var recursive bool = true
// The root command for the CLI which passes the flags to the [godoc_readme package](../godoc_readme/README.md)
var rootCmd = &cobra.Command{
Use: "godoc-readme",
Short: "Generate README.md file for your go project using comments you already write",
Long: `Generate README.md file for your go project using comments you already write`,
Run: func(cmd *cobra.Command, args []string) {
if readme, err := godoc_readme.NewReadme(func(ro *godoc_readme.ReadmeOptions) {
ro.PackageDir = package_root
if recursive {
ro.PackageDir = "./..."
}
ro.Env = strings.Split(env, "")
ro.ConfirmUpdates = confirm_updates
ro.Flags = flags
}); err != nil {
fmt.Println("err")
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
} else {
if err = readme.Generate(); err != nil {
fmt.Println("Generate err")
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
},
}
Examples
Example_help_command
func Example_help_command{
Execute("-h")
}
// Output:
//
// Generate README.md file for your go project using comments you already write
//
// Usage:
// godoc-readme [flags]
//
// Flags:
// -c, --confirm-updates Use this flag to confirm overwriting existing README.md files. The default behaviour is to overwrite the file without confirmation. Confirmation also gives you the option to view the diff between the existing and generated file before overwriting it.
// -h, --help help for godoc-readme
// -r, --recursive If set, recursively search for go packages in the directory and generate a README.md for each package; Default will only create a Readme for the package found in the current directory
// --skip-examples Skips generating the examples defined in test files
//