Skip to content

Commit

Permalink
Merge pull request #51 from gen0cide/replmigration
Browse files Browse the repository at this point in the history
finishing up 0.1.0 release
  • Loading branch information
gen0cide authored Mar 11, 2018
2 parents ca8bc87 + f93c752 commit 4ba07d9
Show file tree
Hide file tree
Showing 63 changed files with 347 additions and 3,672 deletions.
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

0 comments on commit 4ba07d9

Please sign in to comment.