From b11838da3f431ae2a728257a86481455021f9b84 Mon Sep 17 00:00:00 2001 From: Ahsanul Haque Date: Fri, 12 Dec 2014 00:05:02 +0600 Subject: [PATCH] Commented commands package --- commands/hugo.go | 10 +++++++++- commands/new.go | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/commands/hugo.go b/commands/hugo.go index 45eed3e28..645dcb825 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -11,6 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//Package commands defines and implements command-line commands and flags used by Hugo. Commands and flags are implemented using +//cobra. package commands import ( @@ -36,7 +38,7 @@ import ( "github.com/spf13/viper" ) -//var Config *hugolib.Config +//HugoCmd is Hugo's root command. Every other command attached to HugoCmd is a child command to it. var HugoCmd = &cobra.Command{ Use: "hugo", Short: "Hugo is a very fast static site generator", @@ -52,14 +54,17 @@ Complete documentation is available at http://gohugo.io`, var hugoCmdV *cobra.Command +//Flags that are to be added to commands. var BuildWatch, Draft, Future, UglyUrls, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles, NoTimes bool var Source, Destination, Theme, BaseUrl, CfgFile, LogFile string +//Execute adds all child commands to the root command HugoCmd and sets flags appropriately. func Execute() { AddCommands() utils.StopOnErr(HugoCmd.Execute()) } +//AddCommands adds child commands to the root command HugoCmd. func AddCommands() { HugoCmd.AddCommand(serverCmd) HugoCmd.AddCommand(version) @@ -70,6 +75,7 @@ func AddCommands() { HugoCmd.AddCommand(listCmd) } +//Initializes flags func init() { HugoCmd.PersistentFlags().BoolVarP(&Draft, "buildDrafts", "D", false, "include content marked as draft") HugoCmd.PersistentFlags().BoolVarP(&Future, "buildFuture", "F", false, "include content with datePublished in the future") @@ -92,6 +98,7 @@ func init() { hugoCmdV = HugoCmd } +// InitializeConfig initializes a config file with sensible default configuration flags. func InitializeConfig() { viper.SetConfigFile(CfgFile) viper.AddConfigPath(Source) @@ -297,6 +304,7 @@ func buildSite(watching ...bool) (err error) { return nil } +//NewWatcher creates a new watcher to watch filesystem events. func NewWatcher(port int) error { if runtime.GOOS == "darwin" { tweakLimit() diff --git a/commands/new.go b/commands/new.go index 4a6e1d278..26e7ff45b 100644 --- a/commands/new.go +++ b/commands/new.go @@ -72,6 +72,7 @@ as you see fit. Run: NewTheme, } +//NewContent adds new content to a Hugo site. func NewContent(cmd *cobra.Command, args []string) { InitializeConfig() @@ -103,6 +104,7 @@ func NewContent(cmd *cobra.Command, args []string) { } } +// NewSite creates a new hugo site and initializes a structured Hugo directory. func NewSite(cmd *cobra.Command, args []string) { if len(args) < 1 { cmd.Usage() @@ -132,6 +134,7 @@ func NewSite(cmd *cobra.Command, args []string) { createConfig(createpath, configFormat) } +//NewTheme creates a new Hugo theme. func NewTheme(cmd *cobra.Command, args []string) { InitializeConfig()