mirror of
https://github.com/lancatlin/mdsh.git
synced 2026-11-05 19:30:12 +08:00
feat: input and output file
This commit is contained in:
1 parent
12dcbb460c
commit
3eae45479b
6 files changed
+64
-18
No files matched your search
@@ -3,14 +3,16 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func parseParams(meta TemplateMeta) (ctx TemplateContext, err error) {
|
||||
result := make(map[string]*string)
|
||||
fs := flag.NewFlagSet("params", flag.ExitOnError)
|
||||
for key, spec := range meta.Params {
|
||||
result[key] = flag.String(key, spec.Default, key)
|
||||
result[key] = fs.String(key, spec.Default, key)
|
||||
}
|
||||
flag.Parse()
|
||||
fs.Parse(os.Args[2:])
|
||||
ctx = make(TemplateContext)
|
||||
for key, spec := range meta.Params {
|
||||
if spec.Required && *result[key] == "" {
|
||||
|
||||
Reference in new issue
Block a user