Update cheat

python3 + add color + remove sheet
This commit is contained in:
Erreur32 2018-02-24 17:42:32 +01:00 committed by GitHub
parent aa1e12625e
commit fec0382892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,28 +1,30 @@
#!/usr/bin/env python
#!/usr/bin/python3
"""cheat
Create and view cheatsheets on the command line.
Usage:
cheat <cheatsheet>
cheat -e <cheatsheet>
cheat -s <keyword>
cheat -l
cheat -d
cheat -v
\033[1;32mcheat\033[0m <cheatsheet>
\033[1;32mcheat\033[0m -e <cheatsheet>
\033[1;32mcheat\033[0m -s <keyword> [<cheatsheet>]
\033[1;32mcheat\033[0m -l
\033[1;32mcheat\033[0m -d
\033[1;32mcheat\033[0m -v
\033[1;32mcheat\033[0m -r <cheatsheet>
Options:
-d --directories List directories on CHEATPATH
-e --edit Edit cheatsheet
-l --list List cheatsheets
-s --search Search cheatsheets for <keyword>
-s --search Search cheatsheets for <keyword> and [<cheatsheet>] file
-v --version Print the version number
-r --remove Delete Cheatsheet
Examples:
To view the `tar` cheatsheet:
cheat tar
\033[1;31m cheat \033[0m tar
To edit (or create) the `foo` cheatsheet:
cheat -e foo
@ -58,7 +60,11 @@ if __name__ == '__main__':
# search among the cheatsheets
elif options['--search']:
print(colorize(sheets.search(options['<keyword>'])))
print(colorize(sheets.search(options['<keyword>'], options['<cheatsheet>'])))
# remove File in the cheatsheets
elif options['--remove']:
sheet.remove(options['<cheatsheet>'])
# print the cheatsheet
else: