forked from gnolang/gno
-
-
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.
feat: add contribs/gnomd (gnolang#1256)
This PR adds a `contribs/gnomd` binary. Please review PR gnolang#1001 for the `maketx run`. Additionally, this PR introduces the `contribs/` folder. It allows the creation of `contribs/gno*` Go packages, Python/Rust/Shell/… scripts. This approach keeps the main `gno`, `gnokey`, and `gnoland` simple while adhering to the Unix philosophy and incorporating several specific gno commands. ![CleanShot 2023-10-19 at 09 17 40@2x](https://github.com/gnolang/gno/assets/94029/9b92bf18-f923-4f70-aea7-a88f185f2342) --------- Signed-off-by: moul <[email protected]> Co-authored-by: Morgan <[email protected]>
- Loading branch information
Showing
7 changed files
with
218 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: contribs | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
paths: | ||
- "contribs/**" | ||
- ".github/workflows/contribs.yml" | ||
- "gnovm/**.go" | ||
- "gno.land/**.go" | ||
- "tm2/**.go" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
install: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
goversion: # two latest versions | ||
- "1.21.x" | ||
program: | ||
- "gnomd" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.goversion }} | ||
- run: make install ${{ matrix.program }} | ||
working-directory: contribs |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.PHONY: help | ||
help: | ||
@echo "Available make commands:" | ||
@cat Makefile | grep '^[a-z][^:]*:' | cut -d: -f1 | sort | sed 's/^/ /' | ||
|
||
.PHONY: install | ||
install: install.gnomd | ||
|
||
install.gnomd:; cd gnomd && go install . | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf build | ||
|
||
######################################## | ||
# Dev tools | ||
rundep=go run -modfile ../misc/devdeps/go.mod | ||
|
||
.PHONY: fmt | ||
GOFMT_FLAGS ?= -w | ||
fmt: | ||
$(rundep) mvdan.cc/gofumpt $(GOFMT_FLAGS) . | ||
|
||
######################################## | ||
# Test suite | ||
GOTEST_FLAGS ?= -v -p 1 -timeout=30m | ||
|
||
.PHONY: test | ||
test: | ||
@echo "nothing to do." |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Gno Contribs | ||
|
||
This directory houses additional commands and tools designed to enhance your Gno experience. | ||
These tools can range from simple wrappers for `gno`, `gnoland`, and `gnokey` to complete applications. | ||
Some may be Go binaries with their own `go.mod` files, allowing the use of specialized libraries, | ||
while others may be shell scripts or programs written in different languages. | ||
|
||
## Contributing Guidelines | ||
|
||
If you'd like to contribute a tool to Gno Contribs, please follow these guidelines: | ||
|
||
1. **Naming**: Choose a clear and concise name for your tool, starting with one of the prefixes: `gno`, `gnoland`, or `gnokey`, | ||
followed by a short descriptive word or abbreviation. | ||
This naming convention helps users identify the purpose of the tool easily. | ||
|
||
2. **User-Friendly**: Ensure that your tool is user-friendly and follows a similar style to other Gno tools, | ||
providing a consistent experience for users. |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module github.com/gnolang/gno/contribs/gnomd | ||
|
||
go 1.20 | ||
|
||
require github.com/MichaelMure/go-term-markdown v0.1.4 | ||
|
||
require ( | ||
github.com/MichaelMure/go-term-text v0.3.1 // indirect | ||
github.com/alecthomas/chroma v0.7.1 // indirect | ||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect | ||
github.com/disintegration/imaging v1.6.2 // indirect | ||
github.com/dlclark/regexp2 v1.1.6 // indirect | ||
github.com/eliukblau/pixterm/pkg/ansimage v0.0.0-20191210081756-9fb6cf8c2f75 // indirect | ||
github.com/fatih/color v1.9.0 // indirect | ||
github.com/gomarkdown/markdown v0.0.0-20191123064959-2c17d62f5098 // indirect | ||
github.com/kyokomi/emoji/v2 v2.2.8 // indirect | ||
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect | ||
github.com/mattn/go-colorable v0.1.4 // indirect | ||
github.com/mattn/go-isatty v0.0.11 // indirect | ||
github.com/mattn/go-runewidth v0.0.12 // indirect | ||
github.com/rivo/uniseg v0.1.0 // indirect | ||
golang.org/x/image v0.0.0-20191206065243-da761ea9ff43 // indirect | ||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect | ||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
|
||
markdown "github.com/MichaelMure/go-term-markdown" | ||
) | ||
|
||
func main() { | ||
// If no arguments are provided, read from stdin | ||
if len(os.Args) <= 1 { | ||
fileContent, err := ioutil.ReadAll(os.Stdin) | ||
checkErr(err) | ||
renderMarkdown("stdin.gno", fileContent) | ||
} | ||
|
||
// Iterate through command-line arguments (file paths) | ||
for _, filePath := range os.Args[1:] { | ||
fileContent, err := ioutil.ReadFile(filePath) | ||
checkErr(err) | ||
renderMarkdown(filePath, fileContent) | ||
} | ||
} | ||
|
||
func renderMarkdown(filePath string, fileContent []byte) { | ||
fmt.Printf("-- %s --\n", filePath) | ||
|
||
result := markdown.Render(string(fileContent), 80, 6) | ||
fmt.Println(string(result)) | ||
} | ||
|
||
func checkErr(err error) { | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |