forked from harry-hov/gnopls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Norman Meier <[email protected]>
- Loading branch information
Showing
11 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
package tools | ||
|
||
import ( | ||
"log/slog" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// Build a Gno package: gno transpile -gobuild <dir>. | ||
// TODO: Remove this in the favour of directly using tools/transpile.go | ||
func Build(rootDir string) ([]byte, error) { | ||
return exec.Command("gno", "transpile", "-skip-imports", "-gobuild", filepath.Join(rootDir)).CombinedOutput() | ||
args := []string{"transpile", "-skip-imports", "-gobuild", filepath.Join(rootDir)} | ||
srcPathsStr := os.Getenv("GNOSRCPATHS") | ||
if srcPathsStr != "" { | ||
args = append(args, "-extra-dirs", srcPathsStr) | ||
} | ||
slog.Info("will run", slog.String("cmd", strings.Join(append([]string{"gno"}, args...), " "))) | ||
return exec.Command("gno", args...).CombinedOutput() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package tools | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
// Transpile a Gno package: gno transpile <dir>. | ||
func Transpile(rootDir string) ([]byte, error) { | ||
return exec.Command("gno", "transpile", "-skip-imports", filepath.Join(rootDir)).CombinedOutput() | ||
args := []string{"transpile", "-skip-imports", filepath.Join(rootDir)} | ||
srcPathsStr := os.Getenv("GNOSRCPATHS") | ||
if srcPathsStr != "" { | ||
args = append(args, "-extra-dirs", srcPathsStr) | ||
} | ||
return exec.Command("gno", args...).CombinedOutput() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
package main | ||
|
||
import "github.com/gnolang/gnopls/cmd" | ||
import ( | ||
"log/slog" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/gnolang/gnopls/cmd" | ||
slogmulti "github.com/samber/slog-multi" | ||
) | ||
|
||
func main() { | ||
userHomeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
panic(err) | ||
} | ||
logFilePath := filepath.Join(userHomeDir, "gnopls.log") | ||
logFile, err := os.OpenFile(logFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer logFile.Close() | ||
logger := slog.New( | ||
slogmulti.Fanout( | ||
slog.NewTextHandler(logFile, &slog.HandlerOptions{}), // pass to first handler: logstash over tcp | ||
slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{}), // then to second handler: stderr | ||
), | ||
) | ||
slog.SetDefault(logger) | ||
cmd.Execute() | ||
} |