Created
June 30, 2018 05:49
-
-
Save dylan-chong/ecf701b1a623c9f2ccb78cbb5db700c6 to your computer and use it in GitHub Desktop.
Grab --options from a help page
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
#!/bin/bash | |
options_for_command() { | |
git help $1 \ | |
| tr " " "\n" \ | |
| egrep '^\--.*$' \ | |
| egrep -v '/' \ | |
| egrep -v '\-{3,}' \ | |
| egrep -v '{|}' \ | |
| perl -pe 's/\[=.*\]//' \ | |
| perl -pe 's/[^\w=\n\[\]<>-]//' \ | |
| perl -pe 's/([^=]+)=.*/\1=/' \ | |
| perl -pe 's/<.*>//' \ | |
| perl -pe 's/^\[(.*)\]$/\1/' \ | |
| perl -pe 's/^([^\[\]]+)\]+$/\1/' \ | |
| sort \ | |
| uniq \ | |
| perl -pe "s/(.*)(\n?)/'\1', /" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful bash script for grabbing all of the options from all help pages. Note
that it does not pick up sub commands like 'save' in
git stash save
. It is alsonot perfect, so will pick up things like '--some-option).' unintentionally.