[
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\n\non: push\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n      - name: Install Fish\n        run: |\n          sudo apt-add-repository -yn ppa:fish-shell/release-3\n          sudo apt-get update\n          sudo apt-get install -y fish\n\n      - name: Install Tools\n        run: |\n          curl -sL https://git.io/fisher | source\n          fisher install jorgebucaran/fishtape $GITHUB_WORKSPACE\n          fishtape tests/*.fish\n        shell: fish {0}\n"
  },
  {
    "path": "LICENSE.md",
    "content": "Copyright © Jorge Bucaran <<https://jorgebucaran.com>>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# spark.fish\n\n> Sparklines for [Fish](https://fishshell.com).\n\nUnofficial port of [spark.sh](https://github.com/holman/spark) with `--min`, `--max` flags and improved [performance](#performance).\n\n## Installation\n\nInstall with [Fisher](https://github.com/jorgebucaran/fisher):\n\n```console\nfisher install jorgebucaran/spark.fish\n```\n\n## Quickstart\n\nYou want to visualize a range of numbers right in your terminal.\n\n```console\n$ spark 1 2 4 8\n▁▂▄█\n```\n\nAnd here is a sequence of random numbers.\n\n```console\n$ seq 64 | sort --random-sort | spark\n▅▄▂▇▂▅▆▄▃█▂▅▄▁▆▆▃█▄▁▇▅▂▃▇▃▃▄▇▄▅▆▇▂▅▁▇▁▄▂▆▅▃█▇▆▆▅▆▃▄▄▇▃▂▇█▅▃█▁▂▂▆\n```\n\nYou can set the `--min=<number>` or `--max=<number>` values for your sparkline too.\n\n```console\n$ seq 10 20 | spark\n▁▂▂▃▄▄▅▆▇▇█\n$ seq 10 20 | spark --min=0\n▄▅▅▆▆▆▇▇▇██\n$ seq 10 20 | spark --min=0 --max=30\n▃▄▄▄▄▄▅▅▅▅▆\n```\n\n## Wicked Cool Usage\n\n> Most of the examples in this section are derived from the original [Wicked Cool Usage](https://github.com/holman/spark/wiki/Wicked-Cool-Usage) wiki, ported to Fish.\n\nLine lengths.\n\n```console\n$ awk \\$0=length (functions --details spark) | spark\n▃▆▃▃▃▄▃▂▄▄▄▅▂▄▅▂▆▁▅▂▅▅▃▂▂▆▃█▂▁▁▁\n```\n\nNumber of commits in a repo, by author.\n\n```console\n$ git shortlog --summary | string match --regex \"\\d+\" | spark\n█▁▁▁▃▁▁▄▁▁▁\n```\n\nTotal run time of processes.\n\n```console\n$ ps -A | string replace --filter --regex -- \".*(\\d+):(\\d+).*\" \"\\$1 * 3600 + \\$2 * 60\" | bc | spark\n▇▁▂▁▆▁▂▂▁▃▁▃▁▁▁▆▁▁▁▂▁▃▂▁▁▃▁▁▁▁▁▂▁▁▂▁▁▁▁▁▆▂▃▂▁▂▃▁▆▁▁▁▂▁▁▁▁▃▂▂▁▇▁▁▁▁▆\n```\n\nLOC added per commit over the last week.\n\n```console\n$ git diff @~7 --numstat | string replace --regex -- \"(^\\d+).*\" \"\\$1\" | spark\n▁▁▁▁▁▁▁▁▂▁▁▁▁▁▁▂▂▃█▄▁▁\n```\n\nA moving wave through the terminal.\n\n```fish\nfor i in (seq 100)\n   for j in (seq (math $COLUMNS - 1))\n      math \"ceil(6 * cos(($i + $j) * pi / 5))\"\n   end | spark | read sparks\n   echo -n $sparks\\r && sleep .1\nend\n```\n\n```console\n▆▄▂▁▂▄▆▇█▇▆▄▂▁▂▄▆▇█▇▆▄▂▁▂▄▆▇█▇▆▄▂▁▂▄▆▇█▇▆▄▂▁▂▄▆▇█▇▆▄▂▁▂▄▆▇█\n```\n\n## Performance\n\nSpark is faster than [`spark.sh`](https://github.com/holman/spark), reading and writing relatively large datasets under milliseconds.\n\n```console\n$ time seq 2000 | sort --random-sort | spark\n________________________________________________________\nExecuted in   27.21 millis    fish           external\n   usr time   26.40 millis    0.57 millis   25.83 millis\n   sys time    4.87 millis    1.58 millis    3.29 millis\n\n$ time seq 2000 | sort --random-sort | spark.sh\n________________________________________________________\nExecuted in    2.73 secs    fish           external\n   usr time    2.72 secs    0.33 millis    2.72 secs\n   sys time    0.02 secs    1.47 millis    0.02 secs\n```\n\n## License\n\n[MIT](LICENSE.md)\n"
  },
  {
    "path": "completions/spark.fish",
    "content": "complete --command spark --exclusive --long min --description \"Minimum range\"\ncomplete --command spark --exclusive --long max --description \"Maximum range\"\ncomplete --command spark --exclusive --long version --description \"Print version\"\ncomplete --command spark --exclusive --long help --description \"Print this help message\"\n"
  },
  {
    "path": "functions/spark.fish",
    "content": "function spark --description Sparklines\n    argparse --ignore-unknown --name=spark v/version h/help m/min= M/max= -- $argv || return\n\n    if set --query _flag_version[1]\n        echo \"spark, version 1.1.0\"\n    else if set --query _flag_help[1]\n        echo \"Usage: spark <numbers ...>\"\n        echo \"       stdin | spark\"\n        echo \"Options:\"\n        echo \"       --min=<number>   Minimum range\"\n        echo \"       --max=<number>   Maximum range\"\n        echo \"       -v or --version  Print version\"\n        echo \"       -h or --help     Print this help message\"\n        echo \"Examples:\"\n        echo \"       spark 1 1 2 5 14 42\"\n        echo \"       seq 64 | sort --random-sort | spark\"\n    else if set --query argv[1]\n        printf \"%s\\n\" $argv | spark --min=\"$_flag_min\" --max=\"$_flag_max\"\n    else\n        command awk -v min=\"$_flag_min\" -v max=\"$_flag_max\" '\n            {\n                m = min == \"\" ? m == \"\" ? $0 : m > $0 ? $0 : m : min\n                M = max == \"\" ? M == \"\" ? $0 : M < $0 ? $0 : M : max\n                nums[NR] = $0\n            }\n            END {\n                n = split(\"▁ ▂ ▃ ▄ ▅ ▆ ▇ █\", sparks, \" \") - 1\n                while (++i <= NR) \n                    printf(\"%s\", sparks[(M == m) ? 3 : sprintf(\"%.f\", (1 + (nums[i] - m) * n / (M - m)))])\n            }\n        ' && echo\n    end\nend\n"
  },
  {
    "path": "tests/spark.fish",
    "content": "@test \"one\" (spark 1) = ▃\n@test \"constant\" (spark 5 5) = ▃▃\n@test \"pyramid\" (spark 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1) = ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁\n@test \"distance\" (spark 1 5 10 15 20) = (spark 10 50 100 150 200)\n@test \"upstairs\" (spark 990 993 996) = ▁▄█\n@test \"fedora\" (spark -5 3 2 -1 -5) = ▁█▇▄▁\n@test \"downstairs\" (spark -500 -501 -502) = █▄▁\n@test \"sinewave\" (spark 2 -1 -4 -6 -4 -1 2 5 6 5 2 -1 -4 -6 -4 -1 2) = ▆▄▂▁▂▄▆▇█▇▆▄▂▁▂▄▆\n@test \"stdin\" (seq 8 | spark) = ▁▂▃▄▅▆▇█\n@test \"indefinite\" (spark 25 45) = ▁█\n@test \"definite\" (spark 0 25 45) = ▁▅█\n@test \"25,45 min=0\" (spark --min=0 -- 25 45) = ▅█\n@test \"5,6,7 min=0\" (spark --min=0 -- 5 6 7) = ▆▇█\n@test \"squash\" (spark --max=10 -- 1 5 1) = ▁▄▁\n"
  }
]