Esempio n. 1
0
func (command *Xlsx2Yaml) Execute(context *console.Context) error {
	if command.filePath == "" {
		if context.FlagSet().NArg() == 1 {
			command.filePath = context.FlagSet().Arg(0)
		} else {
			return fmt.Errorf("need input file")
		}
	}
	rawArray, err := kmgExcel.XlsxFile2Array(command.filePath)
	if err != nil {
		return err
	}
	output, err := command.formatOutput(rawArray)
	if err != nil {
		return err
	}
	outByte, err := kmgYaml.Marshal(output)
	if err != nil {
		return err
	}
	_, err = context.Stdout.Write(outByte)
	if err != nil {
		return err
	}
	return nil
}
Esempio n. 2
0
func (command *ParpareReflect) Execute(context *console.Context) error {
	//parse all file in GOPATH
	wd, err := os.Getwd()
	if err != nil {
		return err
	}
	root := filepath.Join(wd, "src")
	contextDecl, err := kmgReflect.NewContextDeclFromSrcPath(root)
	if err != nil {
		return err
	}
	out, err := kmgYaml.Marshal(contextDecl)
	if err != nil {
		return err
	}

	_, err = context.Stdout.Write(out)
	if err != nil {
		return err
	}
	return nil
}