@aryanbhosale/pick 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -20
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Extract values from anything — JSON, YAML, TOML, .env, HTTP headers, logfmt, C
|
|
|
11
11
|
npm install -g @aryanbhosale/pick
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
`pick` auto-detects the input format and lets you extract values using a
|
|
14
|
+
`pick` auto-detects the input format and lets you extract, filter, and transform values using a unified selector syntax. Think of it as **jq for all config formats**.
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
@@ -54,14 +54,59 @@ cat data.csv | pick '[0].name'
|
|
|
54
54
|
| `foo[0]` | Array index |
|
|
55
55
|
| `foo[-1]` | Last element |
|
|
56
56
|
| `foo[*].name` | All elements, pluck field |
|
|
57
|
+
| `foo[1:3]` | Array slice (elements 1 and 2) |
|
|
58
|
+
| `..name` | Recursive descent — find `name` at any depth |
|
|
57
59
|
| `[0]` | Index into root array |
|
|
58
60
|
| `"dotted.key".sub` | Quoted key (for keys containing dots) |
|
|
61
|
+
| `name, age` | Multiple selectors (union) |
|
|
62
|
+
|
|
63
|
+
## Pipes & Filters
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Filter: find expensive items
|
|
67
|
+
cat data.json | pick 'items[*] | select(.price > 100) | name'
|
|
68
|
+
|
|
69
|
+
# Regex match
|
|
70
|
+
cat data.json | pick 'items[*] | select(.email ~ "@gmail") | name'
|
|
71
|
+
|
|
72
|
+
# Boolean logic
|
|
73
|
+
cat data.json | pick 'users[*] | select(.age >= 18 and .active) | name'
|
|
74
|
+
|
|
75
|
+
# Builtins
|
|
76
|
+
cat config.json | pick 'keys()'
|
|
77
|
+
cat config.json | pick 'dependencies | length()'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Mutation
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Set a value
|
|
84
|
+
cat config.json | pick 'set(.version, "2.0")' --json
|
|
85
|
+
|
|
86
|
+
# Delete a key
|
|
87
|
+
cat config.json | pick 'del(.temp)' --json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Output Formats
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
cat data.json | pick -o yaml # Convert to YAML
|
|
94
|
+
cat data.json | pick -o toml # Convert to TOML
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Streaming (JSONL)
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
cat events.jsonl | pick 'user.name' --stream
|
|
101
|
+
cat logs.jsonl | pick 'select(.level == "error") | message' --stream
|
|
102
|
+
```
|
|
59
103
|
|
|
60
104
|
## Flags
|
|
61
105
|
|
|
62
106
|
| Flag | Description |
|
|
63
107
|
|---|---|
|
|
64
108
|
| `-i, --input <format>` | Force input format (`json`, `yaml`, `toml`, `env`, `headers`, `logfmt`, `csv`, `text`) |
|
|
109
|
+
| `-o, --output <format>` | Output format (`json`, `yaml`, `toml`) |
|
|
65
110
|
| `-f, --file <path>` | Read from file instead of stdin |
|
|
66
111
|
| `--json` | Output result as JSON |
|
|
67
112
|
| `--raw` | Output without trailing newline |
|
|
@@ -71,30 +116,12 @@ cat data.csv | pick '[0].name'
|
|
|
71
116
|
| `-q, --quiet` | Suppress error messages |
|
|
72
117
|
| `-e, --exists` | Check if selector matches (exit code only) |
|
|
73
118
|
| `-c, --count` | Count matches |
|
|
119
|
+
| `--stream` | Stream mode: process JSONL line-by-line |
|
|
74
120
|
|
|
75
121
|
## Supported Formats
|
|
76
122
|
|
|
77
123
|
JSON, YAML, TOML, .env, HTTP headers, logfmt, CSV/TSV, and plain text. Format is auto-detected — use `-i` to override.
|
|
78
124
|
|
|
79
|
-
## Pipe-friendly
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# Get all repo names
|
|
83
|
-
curl -s https://api.github.com/users/octocat/repos | pick '[*].name' --lines
|
|
84
|
-
|
|
85
|
-
# Check if key exists
|
|
86
|
-
if cat config.json | pick database.host --exists; then
|
|
87
|
-
DB_HOST=$(cat config.json | pick database.host)
|
|
88
|
-
fi
|
|
89
|
-
|
|
90
|
-
# Extract with fallback
|
|
91
|
-
cat config.yaml | pick server.port --default 3000
|
|
92
|
-
|
|
93
|
-
# Count results
|
|
94
|
-
echo '[1,2,3,4,5]' | pick '[*]' --count
|
|
95
|
-
# 5
|
|
96
|
-
```
|
|
97
|
-
|
|
98
125
|
## Links
|
|
99
126
|
|
|
100
127
|
- [Documentation & examples](https://pick-cli.pages.dev)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aryanbhosale/pick",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Extract values from
|
|
3
|
+
"version": "0.1.22",
|
|
4
|
+
"description": "Extract, filter, and transform values from JSON, YAML, TOML, .env, HTTP headers, logfmt, CSV, and more",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"funding": {
|
|
7
7
|
"type": "github",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"bin"
|
|
40
40
|
],
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@aryanbhosale/pick-darwin-arm64": "0.1.
|
|
43
|
-
"@aryanbhosale/pick-darwin-x64": "0.1.
|
|
44
|
-
"@aryanbhosale/pick-linux-x64": "0.1.
|
|
45
|
-
"@aryanbhosale/pick-linux-arm64": "0.1.
|
|
46
|
-
"@aryanbhosale/pick-win32-x64": "0.1.
|
|
42
|
+
"@aryanbhosale/pick-darwin-arm64": "0.1.22",
|
|
43
|
+
"@aryanbhosale/pick-darwin-x64": "0.1.22",
|
|
44
|
+
"@aryanbhosale/pick-linux-x64": "0.1.22",
|
|
45
|
+
"@aryanbhosale/pick-linux-arm64": "0.1.22",
|
|
46
|
+
"@aryanbhosale/pick-win32-x64": "0.1.22"
|
|
47
47
|
}
|
|
48
48
|
}
|