Created
December 9, 2016 20:19
-
-
Save colstrom/4bc0a271d5f44104d192c8797ba7a027 to your computer and use it in GitHub Desktop.
gistpkg-manifest.fish: generate gistpkg.zpl from a .fish function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function gistpkg-manifest --argument file | |
| switch (count $argv) | |
| case 0 | |
| echo 'usage: gistpkg-manifest <file>' | |
| return 100 | |
| case '*' | |
| set name (basename -s .fish $file) | |
| printf "name = %s\n\n" $name | |
| set --query GISTPKG_AUTHOR | |
| and printf "author = %s\n\n" "$GISTPKG_AUTHOR" | |
| set --query GISTPKG_LICENSE | |
| and printf "license = %s\n\n" "$GISTPKG_LICENSE" | |
| printf "provides = fish/functions/%s\n\n" (basename -s .fish $file) | |
| printf "requires\n" | |
| sonar-lexer (cat $file) | sort -u | while read type token | |
| switch $type | |
| case t_builtin | |
| printf " fish/builtin/%s\n" $token | |
| case t_function | |
| printf " fish/functions/%s\n" $token | |
| case t_command | |
| printf " command/%s\n" $token | |
| end | |
| end | sort | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name = gistpkg-manifest | |
| author = Chris Olstrom | |
| license = MIT | |
| provides = fish/functions/gistpkg-manifest | |
| requires | |
| command/basename | |
| command/cat | |
| command/sort | |
| fish/builtin/and | |
| fish/builtin/case | |
| fish/builtin/count | |
| fish/builtin/echo | |
| fish/builtin/end | |
| fish/builtin/function | |
| fish/builtin/printf | |
| fish/builtin/read | |
| fish/builtin/return | |
| fish/builtin/set | |
| fish/builtin/switch | |
| fish/builtin/while | |
| fish/functions/sonar-lexer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment