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
1 changed files with 16 additions and 10 deletions

View File

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