Selaa lähdekoodia

Allow specifying the output file in the YAML prefix

Lucas Stadler 9 vuotta sitten
vanhempi
commit
575f389259
2 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 12 0
      go/blog/blog.go
  2. 1 0
      go/blog/blog.yaml

+ 12 - 0
go/blog/blog.go

39
	NoDefaultStyle bool   `yaml:"no_default_style"`
39
	NoDefaultStyle bool   `yaml:"no_default_style"`
40
	Title          string `yaml:"title"`
40
	Title          string `yaml:"title"`
41
	After          string `yaml:"after"`
41
	After          string `yaml:"after"`
42
43
	// options only in the YAML prefix:
44
45
	Output string `yaml:"output"`
42
}
46
}
43
47
44
var flags struct {
48
var flags struct {
220
				flags.After = opts.After
224
				flags.After = opts.After
221
			}
225
			}
222
		})
226
		})
227
228
		// write to specified `output` file if none was given as an argument
229
		if opts.Output != "" && out == os.Stdout {
230
			out, err = os.Create(opts.Output)
231
			if err != nil {
232
				exit(err)
233
			}
234
		}
223
	}
235
	}
224
236
225
	var posts []Post
237
	var posts []Post

+ 1 - 0
go/blog/blog.yaml

1
title: A test blog
1
title: A test blog
2
reverse: true
2
reverse: true
3
output: blog.html
3
---
4
---
4
- title: pacman -Qo $(ls -1t --time=atime /usr/bin | tail -n30)
5
- title: pacman -Qo $(ls -1t --time=atime /usr/bin | tail -n30)
5
  content:
6
  content: