From f930152424c63d858ba50c3b82460f4857716eb8 Mon Sep 17 00:00:00 2001 From: surdeus Date: Tue, 9 Jul 2024 16:13:20 +0500 Subject: [PATCH] init --- .gitignore | 1 + build.sh | 3 +++ cmd/gore/main.go | 21 +++++++++++++++++++++ enc/enc.go | 27 +++++++++++++++++++++++++++ go.mod | 5 +++++ go.sum | 2 ++ 6 files changed, 59 insertions(+) create mode 100644 .gitignore create mode 100755 build.sh create mode 100644 cmd/gore/main.go create mode 100644 enc/enc.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f655bb0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/exe/ diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..9fa60ed --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +go build -o ./exe/ ./cmd/gore diff --git a/cmd/gore/main.go b/cmd/gore/main.go new file mode 100644 index 0000000..9f9507a --- /dev/null +++ b/cmd/gore/main.go @@ -0,0 +1,21 @@ +package main + +import "surdeus.su/core/cli/mtool" +import "surdeus.su/util/gore/enc" +import "encoding/hex" +import "os" + + +var root = mtool.T("gore").Subs( + mtool.T("encode").Subs( + enc.NewEncodeTool( + "hex", + hex.NewEncoder, + ), + ), +) + +func main() { + root.Run(os.Args[1:]) +} + diff --git a/enc/enc.go b/enc/enc.go new file mode 100644 index 0000000..ce8984d --- /dev/null +++ b/enc/enc.go @@ -0,0 +1,27 @@ +package enc + +import "surdeus.su/core/cli/mtool" +import "io" +import "os" + +type EncodeOptions struct { +} + +func NewEncodeTool( + name string, + encFn func (io.Writer) io.Writer, +) *mtool.Tool { + ret := mtool.T(name).Func(func(flags *mtool.Flags){ + //var opts EncodeOptions + _ = flags.Parse() + + input := os.Stdin + output := os.Stdout + + encOutput := encFn(output) + io.Copy(encOutput, input) + }) + + return ret +} + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..56ef35c --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module surdeus.su/util/gore + +go 1.21.7 + +require surdeus.su/core/cli v0.1.2 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..0b79714 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +surdeus.su/core/cli v0.1.2 h1:qPzjawqPyZsO4Z5SaA1u141recVE65yioA83Qs7Jecs= +surdeus.su/core/cli v0.1.2/go.mod h1:r9JtQz3aEJzpYzMaNUNQHJoYkoWKNPi047qhd5uGlmA=