compiler basics

This commit is contained in:
tkarrass 2016-02-06 15:44:09 +01:00
parent e2c33d16a2
commit 2e34a1f4e2
11 changed files with 51 additions and 0 deletions

45
cmd/compile.go Normal file
View File

@ -0,0 +1,45 @@
package cmd // code.bitsetter.de/fun/gosl/cmd
import (
"github.com/spf13/cobra"
"log"
"path"
)
var (
levelDir string
levelFile string
)
var cmdCompile = &cobra.Command{
Use: "compile <leveldir>",
Short: "Compiles a gosl level into a loadable level file",
Long: `Compiles a level file from a given input directory.
It's contents contain at least:
/ leveldir
+-- Manifest.json Basic level Info
+-- Layer1/ At least one layer dir containing
+-- Manifest.json Basic layer Info
+-- 1.Frame At least one frame
See the example level for further details (which does not exist, yet :p)`,
}
func compile(cmd *cobra.Command, args []string) {
if len(args) < 1 {
log.Fatal("You need to specify a level directory to compile!")
}
levelDir = args[0]
if levelFile == "" {
levelFile = path.Base(levelDir) + ".lvl"
}
log.Println("will compile to", levelFile)
}
func init() {
CmdGosl.AddCommand(cmdCompile)
cmdCompile.Run = compile
cmdCompile.Flags().StringVarP(&levelFile, "output", "o", "", "Output filename")
}

View File

@ -2,6 +2,7 @@ package cmd // code.bitsetter.de/fun/gosl/cmd
import (
"encoding/gob"
"fmt"
"log"
"net"
"sort"
@ -68,6 +69,7 @@ func serveClients() {
if id > 0 {
enc := gob.NewEncoder(client.con)
enc.Encode(oFrame)
//log.Println("ID:", id, "Client:", client)
}
}

View File

@ -0,0 +1,4 @@
{
"Name": "The locomotive!",
"FPS": 10
}