mirror of
https://github.com/acaloiaro/struct
synced 2026-07-21 10:12:28 +00:00
54 lines
No EOL
1.7 KiB
Markdown
54 lines
No EOL
1.7 KiB
Markdown
**NOTICE**: This repository has been moved to [https://code.adriano.fyi/me/struct](https://code.adriano.fyi/me/struct). Microsoft has shown little interest in stewarding what was once the best and largest open source community. This small act of migration is my way showing that we don't all support Microsoft's disinterest.
|
|
|
|
# struct
|
|
|
|
A simple cli utility that transforms unstructured input into structured output.
|
|
|
|
# install
|
|
|
|
`$ go get github.com/acaloiaro/struct`
|
|
|
|
# example usage
|
|
|
|
## string output
|
|
```
|
|
$ ls -l | struct -fields permissions,count,user,group,,,,,file_name -output string
|
|
permissions:-rw-r--r-- count:1 user:adriano group:staff 84 Sep 23 22:55 file_name:README.md
|
|
permissions:-rw------- count:1 user:adriano group:staff 39 Sep 23 21:08 file_name:go.mod
|
|
permissions:-rw-r--r-- count:1 user:adriano group:staff 2531 Sep 23 22:54 file_name:struct.go
|
|
```
|
|
|
|
## json output
|
|
|
|
```bash
|
|
$ ls -l | struct -fields permissions,count,user,group,,,,,file_name -output json
|
|
{"count":"1","file_name":"README.md","group":"staff","permissions":"-rw-r--r--","user":"adriano"}
|
|
{"count":"1","file_name":"go.mod","group":"staff","permissions":"-rw-------","user":"adriano"}
|
|
{"count":"1","file_name":"struct.go","group":"staff","permissions":"-rw-r--r--","user":"adriano"}
|
|
```
|
|
|
|
## json output | joining forces with `jq`
|
|
|
|
``` ls -l | struct -fields permissions,count,user,group,,,,,file_name -output json | jq```
|
|
```json
|
|
{
|
|
"count": "1",
|
|
"file_name": "README.md",
|
|
"group": "staff",
|
|
"permissions": "-rw-r--r--",
|
|
"user": "adriano"
|
|
}
|
|
{
|
|
"count": "1",
|
|
"file_name": "go.mod",
|
|
"group": "staff",
|
|
"permissions": "-rw-------",
|
|
"user": "adriano"
|
|
}
|
|
{
|
|
"count": "1",
|
|
"file_name": "struct.go",
|
|
"group": "staff",
|
|
"permissions": "-rw-r--r--",
|
|
"user": "adriano"
|
|
} |