Documentation
¶
Overview ¶
Copyright 2023 prestidigitator (as registered on forum.minetest.net)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 prestidigitator (as registered on forum.minetest.net)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 prestidigitator (as registered on forum.minetest.net)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 prestidigitator (as registered on forum.minetest.net)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MTS2JSON = &cobra.Command{ Use: "mts2json [--indent=n] [mstFile|-] [outFile|-]", Short: "Convert binary MTS schematic file to JSON.", Long: "Read a binary mintest MTS schematic file and dump the output in " + "human-readable JSON format.", Args: cobra.MaximumNArgs(2), ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective, ) { switch len(args) { case 0: return []string{"mts"}, cobra.ShellCompDirectiveFilterFileExt case 1: return nil, cobra.ShellCompDirectiveDefault default: return nil, cobra.ShellCompDirectiveNoFileComp } }, RunE: func(cmd *cobra.Command, args []string) error { flags := cmd.Flags() nIndent, err := flags.GetInt("indent") if err != nil { return err } cmd.SilenceUsage = true indent := "\t" if nIndent >= 0 { indent = strings.Repeat(" ", nIndent) } var ins io.Reader = os.Stdin if len(args) > 0 && args[0] != "-" { file, err := os.Open(args[0]) if err != nil { return err } defer file.Close() ins = file } var outs io.Writer = os.Stdout if len(args) > 1 && args[1] != "-" { file, err := os.Create(args[1]) if err != nil { return err } defer file.Close() outs = file } s, err := schematic.FromMTSStream(ins) if err != nil { return err } return s.WriteJSON(outs, indent) }, }
var MTS2Lua = &cobra.Command{ Use: "mts2lua [--indent=n] [--comments] [mstFile|-] [outFile|-]", Short: "Convert binary MTS schematic file to Lua chunk.", Long: "Read a binary mintest MTS schematic file and dump the output in " + "Lua source code format.", Args: cobra.MaximumNArgs(2), ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective, ) { switch len(args) { case 0: return []string{"mts"}, cobra.ShellCompDirectiveFilterFileExt case 1: return nil, cobra.ShellCompDirectiveDefault default: return nil, cobra.ShellCompDirectiveNoFileComp } }, RunE: func(cmd *cobra.Command, args []string) error { flags := cmd.Flags() nIndent, err := flags.GetInt("indent") if err != nil { return err } comments, err := flags.GetBool("comments") if err != nil { return err } cmd.SilenceUsage = true indent := "\t" if nIndent >= 0 { indent = strings.Repeat(" ", nIndent) } var ins io.Reader = os.Stdin if len(args) > 0 && args[0] != "-" { file, err := os.Open(args[0]) if err != nil { return err } defer file.Close() ins = file } var outs io.Writer = os.Stdout if len(args) > 1 && args[1] != "-" { file, err := os.Create(args[1]) if err != nil { return err } defer file.Close() outs = file } s, err := schematic.FromMTSStream(ins) if err != nil { return err } return s.WriteLua(outs, indent, comments) }, }
var MTS2YAML = &cobra.Command{ Use: "mts2yaml [--indent=n] [mstFile|-] [outFile|-]", Short: "Convert binary MTS schematic file to YAML.", Long: "Read a binary mintest MTS schematic file and dump the output in " + "human-readable YAML format.", Args: cobra.MaximumNArgs(2), ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective, ) { switch len(args) { case 0: return []string{"mts"}, cobra.ShellCompDirectiveFilterFileExt case 1: return nil, cobra.ShellCompDirectiveDefault default: return nil, cobra.ShellCompDirectiveNoFileComp } }, RunE: func(cmd *cobra.Command, args []string) error { flags := cmd.Flags() nIndent, err := flags.GetInt("indent") if err != nil { return err } cmd.SilenceUsage = true indent := "\t" if nIndent >= 0 { indent = strings.Repeat(" ", nIndent) } var ins io.Reader = os.Stdin if len(args) > 0 && args[0] != "-" { file, err := os.Open(args[0]) if err != nil { return err } defer file.Close() ins = file } var outs io.Writer = os.Stdout if len(args) > 1 && args[1] != "-" { file, err := os.Create(args[1]) if err != nil { return err } defer file.Close() outs = file } s, err := schematic.FromMTSStream(ins) if err != nil { return err } return s.WriteYAML(outs, indent) }, }
var YAML2MTS = &cobra.Command{ Use: "yaml2mts [inFile|-] [outFile|-]", Aliases: []string{"json2mts"}, Short: "Convert YAML to binary MTS schematic file.", Long: "Write a binary mintest MTS schematic file given a YAML or JSON input " + "definition.", Args: cobra.MaximumNArgs(2), ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective, ) { switch len(args) { case 0: return []string{"yaml", "json"}, cobra.ShellCompDirectiveFilterFileExt case 1: return []string{"mts"}, cobra.ShellCompDirectiveFilterFileExt default: return nil, cobra.ShellCompDirectiveNoFileComp } }, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true var ins io.Reader = os.Stdin if len(args) > 0 && args[0] != "-" { file, err := os.Open(args[0]) if err != nil { return err } defer file.Close() ins = file } inb, err := io.ReadAll(ins) if err != nil { return err } var outs io.Writer = os.Stdout if len(args) > 1 && args[1] != "-" { file, err := os.Create(args[1]) if err != nil { return err } defer file.Close() outs = file } s, err := schematic.FromJSONStream(bytes.NewReader(inb)) if err != nil { s, err = schematic.FromYAMLStream(bytes.NewReader(inb)) if err != nil { return err } } return s.WriteMTS(outs) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.