Beispiel #1
0
func Get(args []string) {
	if len(args) < 1 {
		fmt.Println("soma get: missing library url(s)")
		fmt.Println(GetUsage)
		os.Exit(1)
	}

	pwd, _ := os.Getwd()
	pd := file.ProjDirFrom(pwd)
	if pd == "" {
		displayGetError("must be called within social machines project", nil)
	}

	for _, url := range args {
		found := brokerHasProjectURL(url)
		if !found {
			fmt.Printf("    NOT FOUND %s\n", url)
			continue
		}

		fmt.Printf("    retrieve %s\n", url)

		writeProjURLToManifest(pd, url)

		name := path.Base(pd)
		fmt.Printf("    appended %s => %s/lib/manifest.sm\n", url, name)
	}
}
Beispiel #2
0
func Serve(args []string) {
	if len(args) < 1 {
		displayServeError("missing broker url", nil)
	}

	pwd, _ := os.Getwd()
	pd := file.ProjDirFrom(pwd)
	if pd == "" {
		displayServeError("must be called within social machines project", nil)
	}

	scope := rt.NewScope(nil)
	_, err := LoadProjectDir(pd, scope)
	if err != nil {
		displayServeError("failed to load project directory", err)
	}

	ln, port := rt.StartListening(10810)
	rt.RT.Port = port

	pname := filepath.Base(pd)
	body := encodeProject(pname, port)
	postErr := postProjectToBroker(args[0], pname, body)
	if postErr != nil {
		displayServeError("failed to post project to broker", err)
	}

	log.Printf("Serving '%s' on %d => %s\n", pname, port, args[0])
	log.Fatal(http.Serve(ln, nil))
}
func StartConsole(ver string) {
	scope := rt.NewScope(nil)

	pwd, _ := os.Getwd()
	pd := file.ProjDirFrom(pwd)
	if pd == "" {
		fmt.Printf("Social Machines (v%s). Type ':exit' to exit.\n", ver)

		startREPL(scope)
	} else {
		ps, err := LoadProjectDir(pd, scope)
		if err != nil {
			displayConsoleError("failed to load project directory", err)
		}

		fmt.Printf("%s // Social Machines (v%s). Type ':exit' to exit.\n", filepath.Base(pd), ver)
		startREPL(ps)
	}
}