// generateDocs represents the generate-docs command
vargenerateDocs=&cobra.Command{
...
...
@@ -38,20 +38,20 @@ var generateDocs = &cobra.Command{
Hidden:true,
Run:func(cmd*cobra.Command,args[]string){
// if directory does not exist
docsPath,err:=os.Stat(path)
iferr!=nil||!docsPath.IsDir(){
st,err:=os.Stat(docsPath)
iferr!=nil||!st.IsDir(){
exit.Message(reason.Usage,"Unable to generate the documentation. Please ensure that the path specified is a directory, exists & you have permission to write to it.")
}
// generate docs
iferr:=generate.Docs(RootCmd,path);err!=nil{
iferr:=generate.Docs(RootCmd,docsPath);err!=nil{
exit.Error(reason.InternalGenerateDocs,"Unable to generate docs",err)
}
out.Step(style.Documentation,"Docs have been saved at - {{.path}}",out.V{"path":path})
out.Step(style.Documentation,"Docs have been saved at - {{.path}}",out.V{"path":docsPath})
},
}
funcinit(){
generateDocs.Flags().StringVar(&path,"path","","The path on the file system where the docs in markdown need to be saved")
generateDocs.Flags().StringVar(&docsPath,"path","","The path on the file system where the docs in markdown need to be saved")