-
Notifications
You must be signed in to change notification settings - Fork 222
feature provide column headers via parameter for asciitable #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Indeed. Either that, or a new parser for headerless ASCII tables that returns an array of arrays:
Use cases would include:
|
We'd need a robust, generalisable solution in Python, but here's a naive, MAS-specific implementation as a shellscript: LIST=$(
mas list |
awk '
{
id = $1
match($0, /\([0-9]/)
version = substr($0, RSTART)
gsub(/\(/, "",version)
gsub(/\)/, "",version)
name = substr($0, index($0, $2), RSTART - index($0, $2) - 1)
gsub(/^[ \t]+|[ \t]+$/, "", name)
print "[\"" id "\", \"" name "\", \"" version "\"],"
}' |
sed '$s/,\s*$//'
)
echo "[\n$LIST\n]" | jq -s '[.[][] | {id: .[0], name: .[1], version: .[2]}]' The naive, MAS-specific implementation returns an object like this: [
{
"id": "1352778147",
"name": "Bitwarden",
"version": "2025.4.2"
},
{
"id": "6448461551",
"name": "Command X",
"version": "1.5.1"
},
{
"id": "409222199",
"name": "Cyberduck",
"version": "9.1.4"
},
{
"id": "1572239625",
"name": "EPUB Viewer Pro",
"version": "5.1.2"
},
{
"id": "880764359",
"name": "Export for iTunes",
"version": "3.7.6"
},
{
"id": "1289583905",
"name": "Pixelmator Pro",
"version": "3.6.18"
},
{
"id": "1611378436",
"name": "Pure Paste",
"version": "1.12.1"
},
{
"id": "1522267256",
"name": "Shareful",
"version": "1.11.0"
},
{
"id": "507257563",
"name": "Sip",
"version": "4.5.2"
},
{
"id": "803453959",
"name": "Slack",
"version": "4.44.60"
},
{
"id": "1666327168",
"name": "Spaced",
"version": "1.2.0"
},
{
"id": "6636491400",
"name": "Text Capture",
"version": "2.0"
},
{
"id": "425424353",
"name": "The Unarchiver",
"version": "4.3.9"
},
{
"id": "1463298887",
"name": "Userscripts",
"version": "4.7.1"
},
{
"id": "1607635845",
"name": "Velja",
"version": "2.1.1"
},
{
"id": "310633997",
"name": "WhatsApp",
"version": "25.15.75"
},
{
"id": "497799835",
"name": "Xcode",
"version": "16.3"
}
] |
One way to do this would be by using environment variables. This way we don't need to add arguments to
We would just need to add env variable functionality to the existing parser code or create new, similar parsers with the capability. |
In fact, the Lines 392 to 399 in ac8120e
So the parser's |
Promising. It's years since I've done anything meaningful with Python so I won't volunteer my own efforts on this one, if that's OK. |
I would like to provide column headers via a parameter for asciitable.
also defining a separator char might be helpfull.
example command:
cat $file | jc --asciitable --headers="a b" --separator=" "
example input file:
aaaaaa xyz
bbbbb uvw
example output:
[{"a": "aaaaaa", "b": "xyz"},{"a": "bbbbb", "b": "uvw"}]
The text was updated successfully, but these errors were encountered: