taskr

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 12 Imported by: 0

README

task-result

task-result (taskr) is output parser for task. It outputs the result of the task in json format that is easy to use in other tools.

Synopsis

$ go run taskr -help
Usage of taskr:
taskr [flags...] source_path
  source_path
        Path to output of task. If set "-", it reads stdin.
  -log-level string
        Log level (trace, debug, info, warn, error, panic) (default "info")
  -out-raw
        Output raw input to stderr
  -version
        Print version

$ task -t testdata/app/parse/Taskfile.yaml 2>&1 | taskr -out-raw - | jq -S
task: [echo] echo "Hello, World!"
[echo] Hello, World!
task: [cal] cal
[cal]      July 2024
[cal] Su Mo Tu We Th Fr Sa
[cal]     1  2  3  4  5  6
[cal]  7  8  9 10 11 12 13
[cal] 14 15 16 17 18 19 20
[cal] 21 22 23 24 25 26 27
[cal] 28 29 30 31
[cal]
task: [ls] ls -la
[ls] total 16
[ls] drwxr-xr-x@ 4 nagata-hiroaki  staff  128 Jul  5 09:54 .
[ls] drwxr-xr-x@ 3 nagata-hiroaki  staff   96 Jul  5 09:54 ..
[ls] -rw-r--r--@ 1 nagata-hiroaki  staff  226 Jul  5 09:54 Taskfile.yaml
[ls] -rw-r--r--@ 1 nagata-hiroaki  staff  598 Jul  5 09:54 out.txt
[
  {
    "cmd": "echo \"Hello, World!\"",
    "name": "echo",
    "output": "Hello, World!\n"
  },
  {
    "cmd": "cal",
    "name": "cal",
    "output": "     July 2024        \nSu Mo Tu We Th Fr Sa  \n    1  2  3  4  5  6  \n 7  8  9 10 11 12 13  \n14 15 16 17 18 19 20  \n21 22 23 24 25 26 27  \n28 29 30 31           \n                      \n"
  },
  {
    "cmd": "ls -la",
    "name": "ls",
    "output": "total 16\ndrwxr-xr-x@ 4 nagata-hiroaki  staff  128 Jul  5 09:54 .\ndrwxr-xr-x@ 3 nagata-hiroaki  staff   96 Jul  5 09:54 ..\n-rw-r--r--@ 1 nagata-hiroaki  staff  226 Jul  5 09:54 Taskfile.yaml\n-rw-r--r--@ 1 nagata-hiroaki  staff  598 Jul  5 09:54 out.txt\n"
  }
]

Installation

$ go get github.com/handlename/task-result/cmd/task-result@latest
$ taskr ...

or

Download latest release binary from Releases

Lisence

MIT

Author

@handlename

Documentation

Index

Constants

View Source
const Version = "0.1.1"

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(level string)

Types

type App

type App struct {
	OutRaw bool
}

func NewApp

func NewApp() *App

func (*App) Parse added in v0.0.2

func (app *App) Parse(_ context.Context, r io.Reader) ([]byte, error)

func (*App) ParseStdin added in v0.0.2

func (app *App) ParseStdin(ctx context.Context) ([]byte, error)

func (*App) Run

func (app *App) Run(ctx context.Context, src io.Reader) error

type Result

type Result struct {
	Name   string `json:"name"`
	Cmd    string `json:"cmd"`
	Output string `json:"output"`
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL