1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 10:54:46 +01:00

Add -s, -d, -h

This commit is contained in:
Oliver Steele 2017-06-23 10:27:57 -04:00
parent 11e8e4c94a
commit a599bbdb6b
2 changed files with 16 additions and 12 deletions

View File

@ -84,7 +84,7 @@ This is currently about 10x slower than using the embedded engine, but still 5x
Neither the embedded Liquid server nor the Liquid Template Server implements very many Jekyll Liquid filters or tags. I'm adding to these as necessary to support my own sites. Neither the embedded Liquid server nor the Liquid Template Server implements very many Jekyll Liquid filters or tags. I'm adding to these as necessary to support my own sites.
## Develop ## Contributing
Install package dependencies and development tools: Install package dependencies and development tools:
@ -92,23 +92,23 @@ Install package dependencies and development tools:
make setup make setup
``` ```
Test: ### Testing
```bash ```bash
make test make test
make lint make lint
gojekyll render index.md # render a file to stdout gojekyll -s path/to/site render index.md # render a file to stdout
gojekyll render / # render a URL to stdout gojekyll -s path/to/site render / # render a URL to stdout
gojekyll variables / # print a file or URL's variables gojekyll -s path/to/site variables / # print a file or URL's variables
./scripts/coverage && go tool cover -html=coverage.out ./scripts/coverage && go tool cover -html=coverage.out
``` ```
`./scripts/gojekyll` is an alternative to the `gojekyll` executable, that uses `go run` each time it's invoked. `./scripts/gojekyll` is an alternative to the `gojekyll` executable, that uses `go run` each time it's invoked.
Profiling: ### Profiling
```bash ```bash
gojekyll --remote-liquid profile gojekyll -s path/to/site profile
go tool pprof gojekyll gojekyll.prof go tool pprof gojekyll gojekyll.prof
``` ```
@ -128,7 +128,7 @@ The gopher image in the test directory is from [Wikimedia Commons](https://commo
[Jekyll](https://jekyllrb.com), of course. [Jekyll](https://jekyllrb.com), of course.
This project is a clean-room implementation of Jekyll, based solely on Jekyll's documentation and testing a few sites. This project is a clean-room implementation of Jekyll, based solely on Jekyll's documentation and testing it against a few sites. Hopefully this can pay off in contributing towards Jekyll's documentation.
## License ## License

View File

@ -17,13 +17,15 @@ var (
useRemoteLiquidEngine bool useRemoteLiquidEngine bool
) )
const defaultDestination = "DEFAULT: ./_"
var ( var (
app = kingpin.New("gojekyll", "a (maybe someday) Jekyll-compatible blog generator in Go") app = kingpin.New("gojekyll", "a (maybe someday) Jekyll-compatible blog generator in Go")
source = app.Flag("source", "Source directory").Default(".").String() source = app.Flag("source", "Source directory").Short('s').Default(".").String()
destination = app.Flag("destination", "Destination directory").Default("").String() destination = app.Flag("destination", "Destination directory").Short('d').Default(defaultDestination).String()
serve = app.Command("serve", "Serve your site locally").Alias("server").Alias("s") serve = app.Command("serve", "Serve your site locally").Alias("server").Alias("s")
open = app.Flag("open-url", "Launch your site in a browser").Short('o').Bool() open = serve.Flag("open-url", "Launch your site in a browser").Short('o').Bool()
build = app.Command("build", "Build your site").Alias("b") build = app.Command("build", "Build your site").Alias("b")
@ -62,10 +64,12 @@ func printPathSetting(label string, name string) {
} }
func main() { func main() {
app.HelpFlag.Short('h')
cmd := kingpin.MustParse(app.Parse(os.Args[1:])) cmd := kingpin.MustParse(app.Parse(os.Args[1:]))
if err := run(cmd); err != nil { if err := run(cmd); err != nil {
app.FatalIfError(err, "") app.FatalIfError(err, "")
} }
} }
func run(cmd string) error { func run(cmd string) error {
site, err := loadSite(*source, *destination) site, err := loadSite(*source, *destination)
@ -97,7 +101,7 @@ func loadSite(source, destination string) (*sites.Site, error) {
return nil, err return nil, err
} }
site.UseRemoteLiquidEngine = useRemoteLiquidEngine site.UseRemoteLiquidEngine = useRemoteLiquidEngine
if destination != "" { if destination != "" && destination != defaultDestination {
site.Destination = destination site.Destination = destination
} }
if site.ConfigFile != nil { if site.ConfigFile != nil {