Commit graph

8 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 4f66f790b1 Add readFile template func
This also includes a refactor of the hugofs package and its usage.

The motivation for that is:

The Afero filesystems are brilliant. Hugo's way of adding a dozen of global variables for the different filesystems was a mistake. In readFile (and also in some other places in Hugo today) we need a way to restrict the access inside the working dir. We could use ioutil.ReadFile and implement the path checking, checking the base path and the dots ("..") etc. But it is obviously better to use an Afero BasePathFs combined witha ReadOnlyFs. We could create a use-once-filesystem and handle the initialization ourselves, but since this is also useful to others and the initialization depends on some other global state (which would mean to create a new file system on every invocation), we might as well do it properly and encapsulate the predefined set of filesystems. This change also leads the way, if needed, to encapsulate the file systems in a struct, making it possible to have several file system sets in action at once (parallel multilanguage site building? With Moore's law and all...)

Fixes #1551
2016-03-31 21:24:18 +02:00
Steve Francia 1d6286b094 update to use cobra's sub package doc 2015-12-24 10:31:44 -05:00
Anthony Fok 8509727fe8 Add copyright header to that source files that don’t have one.
See #1646
2015-12-10 15:19:38 -07:00
Bjørn Erik Pedersen 3f0f7eed68 Improve error handling in commands
Cobra, the CLI commander in use in Hugo, has some long awaited improvements in the error handling department.
This enables a more centralized error handling approach.

This commit introduces that by changing all the command funcs to `RunE`:

* The core part of the error logging, usage logging and `os.Exit(-1)` is now performed in one place and that one place only.
* The usage text is now only shown on invalid arguments etc. (user errors)

Fixes #1502
2015-12-02 07:07:05 -07:00
Anthony Fok 666ddd2377 Enable dirname and filename completion for more flags
These flags are:

 * --source (-s), --cacheDir, --destination (-d) and --logFile
 * --completionfile and --dir.
2015-12-02 02:24:49 -07:00
Anthony Fok 50b5d0af29 Support setting target directory in hugo gen man
Fixes #1627
2015-11-28 07:32:02 -07:00
Bjørn Erik Pedersen 3d09de8910 Restructure the gen commands
Fixes #1603
2015-11-23 16:51:12 +01:00
Anthony Fok 098a0c819a Add commands/genman.go to autogenerate man pages
Fixes #1369
2015-11-22 18:54:44 +01:00