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

feat: add contribs/gnomd #1256

Merged
merged 6 commits into from
Nov 8, 2023
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
35 changes: 35 additions & 0 deletions .github/workflows/contribs.yml
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
5 changes: 3 additions & 2 deletions .github/workflows/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ jobs:

- name: Check go.mods
run: |
sums="$(sha256sum go.mod misc/devdeps/go.mod)"
for path in . ./misc/devdeps; do
gomods=$(find . -type f -name go.mod)
sums="$(sha256sum ${gomods})"
for path in $(dirname $(gomods)); do
env -C $path go mod tidy -v || exit 1
done
echo "$sums" | sha256sum -c
30 changes: 30 additions & 0 deletions contribs/Makefile
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."
17 changes: 17 additions & 0 deletions contribs/README.md
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.
25 changes: 25 additions & 0 deletions contribs/gnomd/go.mod
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
)
70 changes: 70 additions & 0 deletions contribs/gnomd/go.sum

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

38 changes: 38 additions & 0 deletions contribs/gnomd/main.go
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)
}
}
Loading