feat: Add support for tabular/csv data input.
This commit is contained in:
@@ -311,6 +311,74 @@ multi_select_structured() {
|
||||
| pikl --multi --structured
|
||||
}
|
||||
|
||||
# ── Phase 5 demos ────────────────────────────────────────
|
||||
|
||||
csv_table() {
|
||||
echo "CSV table mode. Columns auto-generated from headers." >&2
|
||||
echo "Navigate with j/k, filter normally." >&2
|
||||
echo "" >&2
|
||||
cat <<'CSV' | pikl --input-format csv
|
||||
name,role,language,editor
|
||||
Alice,backend,Rust,Neovim
|
||||
Bob,frontend,TypeScript,VS Code
|
||||
Charlie,devops,Go,Helix
|
||||
Diana,data,Python,Jupyter
|
||||
Eve,security,Rust,Neovim
|
||||
Frank,mobile,Kotlin,IntelliJ
|
||||
CSV
|
||||
}
|
||||
|
||||
tsv_table() {
|
||||
echo "TSV table mode. Same as CSV but tab-delimited." >&2
|
||||
echo "" >&2
|
||||
printf "pid\tuser\tcommand\n101\troot\tinit\n202\tmaple\tnvim\n303\tmaple\tbash\n404\troot\tsshd\n" \
|
||||
| pikl --input-format tsv
|
||||
}
|
||||
|
||||
csv_columns_alias() {
|
||||
echo "CSV with --columns to pick a subset and rename headers." >&2
|
||||
echo "Only showing name and language (aliased to 'Lang')." >&2
|
||||
echo "" >&2
|
||||
cat <<'CSV' | pikl --input-format csv --columns "name,meta.language:Lang"
|
||||
name,role,language,editor
|
||||
Alice,backend,Rust,Neovim
|
||||
Bob,frontend,TypeScript,VS Code
|
||||
Charlie,devops,Go,Helix
|
||||
Diana,data,Python,Jupyter
|
||||
Eve,security,Rust,Neovim
|
||||
CSV
|
||||
}
|
||||
|
||||
csv_multi_select() {
|
||||
echo "CSV + multi-select. Toggle rows with Space, confirm with Enter." >&2
|
||||
echo "" >&2
|
||||
cat <<'CSV' | pikl --input-format csv --multi
|
||||
package,version,size
|
||||
ripgrep,14.1,2.1M
|
||||
fd,10.2,1.8M
|
||||
bat,0.24,3.4M
|
||||
eza,0.18,2.0M
|
||||
delta,0.17,4.2M
|
||||
tokei,12.1,1.5M
|
||||
CSV
|
||||
}
|
||||
|
||||
csv_filter() {
|
||||
echo "CSV with filtering. Type to filter rows, field filters work too." >&2
|
||||
echo "Try: meta.category:rolling" >&2
|
||||
echo "" >&2
|
||||
cat <<'CSV' | pikl --input-format csv
|
||||
label,category,init
|
||||
Arch Linux,rolling,systemd
|
||||
NixOS,rolling,systemd
|
||||
Void Linux,rolling,runit
|
||||
Debian,stable,systemd
|
||||
Alpine,stable,openrc
|
||||
Fedora,semi-rolling,systemd
|
||||
Gentoo,rolling,openrc
|
||||
CSV
|
||||
}
|
||||
|
||||
# ── Scenario menu ─────────────────────────────────────────
|
||||
|
||||
scenarios=(
|
||||
@@ -337,6 +405,12 @@ scenarios=(
|
||||
"Multi-select (packages)"
|
||||
"Multi-select (structured output)"
|
||||
"---"
|
||||
"CSV table (auto columns)"
|
||||
"TSV table (processes)"
|
||||
"CSV with --columns aliases"
|
||||
"CSV + multi-select"
|
||||
"CSV + field filter"
|
||||
"---"
|
||||
"on-select-exec hook (legacy)"
|
||||
)
|
||||
|
||||
@@ -362,6 +436,11 @@ run_scenario() {
|
||||
*"Multi-select (basic)"*) multi_select_basic ;;
|
||||
*"Multi-select (pack"*) multi_select_packages ;;
|
||||
*"Multi-select (struct"*) multi_select_structured ;;
|
||||
*"CSV table"*) csv_table ;;
|
||||
*"TSV table"*) tsv_table ;;
|
||||
*"CSV with --columns"*) csv_columns_alias ;;
|
||||
*"CSV + multi"*) csv_multi_select ;;
|
||||
*"CSV + field"*) csv_filter ;;
|
||||
*"on-select-exec"*) on_select_hook ;;
|
||||
"---")
|
||||
echo "that's a separator, not a scenario" >&2
|
||||
|
||||
Reference in New Issue
Block a user