Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finishing up 0.1.0 release #51

Merged
merged 3 commits into from
Mar 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
331 changes: 311 additions & 20 deletions README.md

Large diffs are not rendered by default.

57 changes: 22 additions & 35 deletions cmd/gscript/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io/ioutil"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
Expand Down Expand Up @@ -48,7 +47,7 @@ func main() {
app.Writer = color.Output
app.ErrWriter = color.Output
app.Name = "gscript"
app.Usage = "Command Line SDK for the Genesis Scripting Engine (GSE)"
app.Usage = "Command Line application for interacting with the GENESIS Scripting Engine."
app.Version = gscript.Version
app.Authors = []cli.Author{
{
Expand All @@ -61,7 +60,7 @@ func main() {
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug, d",
Usage: "Run gscript in debug mode.",
Usage: "Enable verbose output of runtime debugging logs.",
Destination: &enableDebug,
},
}
Expand All @@ -76,13 +75,13 @@ func main() {
{
Name: "shell",
Aliases: []string{"s"},
Usage: "Run an interactive GSE console session.",
Usage: "Run an interactive gscript REPL.",
Action: InteractiveShell,
},
{
Name: "update",
Aliases: []string{"u"},
Usage: "Update Genesis Scripting Engine to the latest version.",
Usage: "Update the gscript CLI binary to the latest version.",
Action: UpdateCLI,
},
{
Expand Down Expand Up @@ -135,7 +134,7 @@ func main() {
{
Name: "run",
Aliases: []string{"r"},
Usage: "Run a Genesis script (Careful, don't infect yourself!).",
Usage: "Run a Genesis script locally (Careful not to infect yourself).",
Action: RunScript,
},
}
Expand All @@ -146,46 +145,31 @@ func main() {
app.Run(os.Args)
}

func TraceScript(c *cli.Context) error {
files := c.Args()
for _, f := range files {
fmt.Printf("Argument: %s\n", f)
fmt.Printf("Base: %s\n", filepath.Base(f))
}
return nil
}

func TestScript(c *cli.Context) error {
logger := logrus.New()
logger.Formatter = &logging.GSEFormatter{}
logger.Out = logging.LogWriter{Name: "test"}
logger.Level = logrus.DebugLevel
logging.PrintLogo()
dbg := debugger.New("runner")
dbg.SetupDebugEngine()
filename := c.Args().Get(0)
if len(filename) == 0 {
logger.Fatalf("You did not supply a filename!")
dbg.Engine.Logger.Fatalf("You did not supply a filename!")
}
if _, err := os.Stat(filename); os.IsNotExist(err) {
logger.Fatalf("File does not exist: %s", filename)
}
_, err := exec.LookPath("jshint")
if err != nil {
logger.Fatalf("You do not have jshint in your path. Run: npm install -g jshint")
dbg.Engine.Logger.Fatalf("File does not exist: %s", filename)
}

jshCmd := exec.Command("jshint", filename)
jshOutput, err := jshCmd.CombinedOutput()
dbg = debugger.New(filepath.Base(filename))
dbg.SetupDebugEngine()
data, err := ioutil.ReadFile(filename)
if err != nil {
logger.Fatalf("File Not Valid Javascript!\n -- JSHint Output:\n%s", jshOutput)
dbg.Engine.Logger.Fatalf("Error reading file: %s", err.Error())
}
data, err := ioutil.ReadFile(filename)
err = compiler.ValidateAST(data)
dbg.LoadScript(string(data), filepath.Base(filename))
if err != nil {
logger.Errorf("Invalid Script Error: %s", err.Error())
} else {
logger.Infof("Script Valid: %s", filename)
dbg.Engine.Logger.Errorf("Script Error: %s", err.Error())
return err
}
dbg.Engine.Logger.Infof("Script is passed static analysis")
return nil

}

func InteractiveShell(c *cli.Context) error {
Expand Down Expand Up @@ -271,6 +255,9 @@ func RunScript(c *cli.Context) error {
}
dbg = debugger.New(filepath.Base(filename))
dbg.SetupDebugEngine()
if !enableDebug {
dbg.Logger.Level = logrus.InfoLevel
}
data, err := ioutil.ReadFile(filename)
if err != nil {
dbg.Engine.Logger.Fatalf("Error reading file: %s", err.Error())
Expand All @@ -285,7 +272,7 @@ func RunScript(c *cli.Context) error {
if err != nil {
dbg.Engine.Logger.Fatalf("Hooks Failure: %s", err.Error())
}
dbg.Engine.Logger.Infof("Hooks executed successfully")
dbg.Engine.Logger.Debugf("Hooks executed successfully")
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion debugger/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func (d *Debugger) LoadScript(script, filename string) error {
})
d.Logger.WithField("file", filename).Debugf("Importing Remote File: %s", name)
}
return d.Engine.LoadScript([]byte(script))
d.Engine.LoadScript(filename, []byte(script))
return nil
}

func (d *Debugger) InteractiveSession() {
Expand Down
88 changes: 0 additions & 88 deletions deprecated/core.go

This file was deleted.

119 changes: 0 additions & 119 deletions deprecated/core_vm.go

This file was deleted.

Loading