Allow .tml and .yml extensions, add nomacro flag

This commit is contained in:
Alex Yatskov 2015-07-20 13:09:08 +09:00
parent 41cfc8c66f
commit db3f4056d5

View File

@ -43,6 +43,7 @@ const (
flagVerbose flagVerbose
flagNoCmd flagNoCmd
flagNoLink flagNoLink
flagNoMacro
) )
func parse(filename string) (*config, error) { func parse(filename string) (*config, error) {
@ -57,11 +58,11 @@ func parse(filename string) (*config, error) {
if err := json.Unmarshal(bytes, &conf); err != nil { if err := json.Unmarshal(bytes, &conf); err != nil {
return nil, err return nil, err
} }
case ".toml": case ".toml", ".tml":
if err := toml.Unmarshal(bytes, &conf); err != nil { if err := toml.Unmarshal(bytes, &conf); err != nil {
return nil, err return nil, err
} }
case ".yaml": case ".yaml", ".yml":
if err := yaml.Unmarshal(bytes, &conf); err != nil { if err := yaml.Unmarshal(bytes, &conf); err != nil {
return nil, err return nil, err
} }
@ -101,6 +102,7 @@ func main() {
verbose := flag.Bool("verbose", false, "verbose output") verbose := flag.Bool("verbose", false, "verbose output")
nocmd := flag.Bool("nocmd", false, "don't execute commands") nocmd := flag.Bool("nocmd", false, "don't execute commands")
nolink := flag.Bool("nolink", false, "don't create links") nolink := flag.Bool("nolink", false, "don't create links")
nomacro := flag.Bool("nomacro", false, "don't execute macros")
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
@ -121,6 +123,9 @@ func main() {
if *nolink { if *nolink {
flags |= flagNoLink flags |= flagNoLink
} }
if *nomacro {
flags |= flagNoMacro
}
if flag.NArg() == 2 { if flag.NArg() == 2 {
confDirAbs := makeAbsPath(flag.Arg(0)) confDirAbs := makeAbsPath(flag.Arg(0))