Skip to content

Commit

Permalink
More builtins, renaming, chores
Browse files Browse the repository at this point in the history
- Add more builtin commands:
  - Remove blank/empty lines (vim)
  - Reverse the order of lines (tac)
  - Shuffle lines (shuf)
  - Sort JSON keys (jq)
- Rename `Reverse (rev)` to `Reverse each line (rev)`
- Add `blank/empty` to several commands related to removal of blank lines for ease of searching
- Add missing `(vim)` suffix to couple of commands
  • Loading branch information
biozz committed Aug 13, 2024
1 parent 16ab8f4 commit 926615d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
20 changes: 12 additions & 8 deletions BUILTINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ This a list of built-in whop commands.
| Build SHA1 (tr, sha1sum) | - |
| Build SHA256 (tr, sha256sum) | - |
| Build SHA512 (tr, sha512sum) | - |
| Reverse (rev) | - |
| Reverse each line (rev) | - |
| Reverse the order of lines (tac) | - |
| Remove all whitespace (tr) | - |
| Remove blank lines (grep) | - |
| Remove blank lines with spaces only (grep) | - |
| Remove blank lines (rg) | - |
| Remove blank lines with spaces only (rg) | - |
| Remove blank/empty lines (grep) | - |
| Remove blank/empty lines with spaces only (grep) | - |
| Remove blank/empty lines (rg) | - |
| Remove blank/empty lines with spaces only (rg) | - |
| Remove blank/empty lines (vim) | - |
| Join lines with comma (vim) | - |
| Wrap numbers with single quotes (vim) | - |
| Wrap numbers with double quotes (vim) | - |
Expand All @@ -38,9 +40,9 @@ This a list of built-in whop commands.
| Replace commas with newlines (vim) | - |
| Ansible Vault Encrypt (ansible-vault) | - |
| Ansible Vault Decrypt (ansible-vault) | - |
| PowerShell escape characters to Unix | - |
| Change single quotes to double quotes | - |
| Change double quotes to single quotes | - |
| PowerShell escape characters to Unix (vim) | - |
| Change single quotes to double quotes (vim) | - |
| Change double quotes to single quotes (vim) | - |
| snake_case to CamelCase (python) | - |
| CamelCase to snake_case (python) | - |
| snake_case to kebab-case (python) | - |
Expand All @@ -50,3 +52,5 @@ This a list of built-in whop commands.
| Generate UUID4 (python) | - |
| Unix timestamp to ISO formatted datetime (python) | - |
| ISO formatted datetime to Unix timestamp (python) | - |
| Shuffle lines (shuf) | - |
| Sort JSON keys (jq) | - |
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2024-08-13 - v1.3.0

- Add more builtin commands:
- Remove blank/empty lines (vim)
- Reverse the order of lines (tac)
- Shuffle lines (shuf)
- Sort JSON keys (jq)
- Rename `Reverse (rev)` to `Reverse each line (rev)`
- Add `blank/empty` to several commands related to removal of blank lines for ease of searching
- Add missing `(vim)` suffix to couple of commands

## 2024-07-10 - v1.2.0

- Add three more builtin commands:
Expand Down
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ Here is a list of things you can do right now to improve this package:
- propose a solution for text-based commands arguments

Here is a list of ideas for builtin commands:
- Sort json
- Markdown quote
- Count characters (view only)
- Count words (view only)
- Shuffle lines
- JSON to Query String
- JSON to YAML
- Lorem ipsum
Expand Down
32 changes: 24 additions & 8 deletions lua/whop/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,37 @@ M.commands = {
cmd = [[%!tr -d '\n' | sha512sum]],
},
{
name = "[builtin] Reverse (rev)",
name = "[builtin] Reverse each line (rev)",
cmd = [[%!rev]],
},
{
name = "[builtin] Reverse the order of lines (tac)",
cmd = [[%!tac]],
},
{
name = "[builtin] Remove all whitespace (tr)",
cmd = [[%!tr -d "[:space:]"]],
},
{
name = "[builtin] Remove blank lines (grep)",
name = "[builtin] Remove blank/empty lines (grep)",
cmd = [[%!grep .]],
},
{
name = "[builtin] Remove blank lines with spaces only (grep)",
name = "[builtin] Remove blank/empty lines with spaces only (grep)",
cmd = [[%!grep "\S"]],
},
{
name = "[builtin] Remove blank lines (rg)",
name = "[builtin] Remove blank/empty lines (rg)",
cmd = [[%!rg -N .]],
},
{
name = "[builtin] Remove blank lines with spaces only (rg)",
name = "[builtin] Remove blank/empty lines with spaces only (rg)",
cmd = [[%!rg -N "\S"]],
},
{
name = "[builtin] Remove blank/empty lines (vim)",
cmd = [[%s/\s*\n//]],
},
{
name = "[builtin] Join lines with comma (vim)",
cmd = [[%s/\n/,/]],
Expand Down Expand Up @@ -140,18 +148,18 @@ M.commands = {
cmd = [[%!ansible-vault decrypt]],
},
{
name = "[builtin] PowerShell escape characters to Unix",
name = "[builtin] PowerShell escape characters to Unix (vim)",
cmd = function()
vim.cmd([[%s/\^$/\\/]])
vim.cmd([[%s/\^\\\^/\\/g]])
end,
},
{
name = "[builtin] Change single quotes to double quotes",
name = "[builtin] Change single quotes to double quotes (vim)",
cmd = [[%s/'/"/g]],
},
{
name = "[builtin] Change double quotes to single quotes",
name = "[builtin] Change double quotes to single quotes (vim)",
cmd = [[%s/"/'/g]],
},
{
Expand Down Expand Up @@ -190,6 +198,14 @@ M.commands = {
name = "[builtin] ISO formatted datetime to Unix timestamp (python)",
cmd = [[%!python -c 'import sys; from datetime import datetime; print(int(datetime.fromisoformat(sys.stdin.read()[:-1]).timestamp()))']],
},
{
name = "[builtin] Shuffle lines (shuf)",
cmd = [[%!shuf]],
},
{
name = "[builtin] Sort JSON keys (jq)",
cmd = [[%!jq --sort-keys]],
},
}

return M

0 comments on commit 926615d

Please sign in to comment.