Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # From: http://applehelpwriter.com/2016/07/02/learning-the-terminal-part-three/
- # start
- (*
- This script produces a summary of all the CLI tools
- in /usr/bin and displays it in a text document
- *)
- set noDocsList to {}
- on extractDescription(aText)
- repeat with i from 1 to count of items in aText
- set this_item to item i of aText
- if this_item contains "NNAAMMEE" then
- set r to item (i + 1) of aText
- try
- set o to offset of "—" in r
- set short_r to text (o + 1) thru -1 of r
- set r to short_r
- end try
- return r
- end if
- end repeat
- end extractDescription
- set theDescriptions to return & return & "**********************************" & return & "SUMMARY OF CLI TOOLS (Version 2)" & return & "**********************************" & return & return & return
- tell application "System Events"
- set theItems to name of every file of folder "bin" of folder "usr" of startup disk
- end tell
- repeat with i from 1 to count of theItems
- set this_item to item i of theItems
- set n_item to length of this_item
- try
- set what_is to do shell script "whatis " & this_item
- if text 1 thru n_item of what_is is this_item and what_is does not contain "nothing appropriate" then
- set theDescriptions to theDescriptions & return & what_is & return
- else
- try
- set getMan to paragraphs of (do shell script "man " & this_item)
- set desc to extractDescription(getMan)
- set what_is to this_item & tab & tab & tab & tab & desc
- set theDescriptions to theDescriptions & return & what_is & return
- on error
- set end of my noDocsList to this_item & return
- end try
- end if
- end try
- end repeat
- set theApp to "TextEdit"
- tell application "Finder"
- if exists POSIX file "/Applications/TextWrangler.app" then
- set theApp to "TextWrangler"
- end if
- end tell
- set theDescriptions to theDescriptions & return & return & return & "The following tools do not have any documentation: " & return & return & noDocsList
- tell application theApp
- activate
- make new document
- set front document's text to my theDescriptions
- end tell
- # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement