mirror of
https://github.com/cheat/cheat.git
synced 2025-09-06 12:03:00 +02:00
Merge branch 'setup-improvements' of https://github.com/youtux/cheat into youtux-setup-improvements
* 'setup-improvements' of https://github.com/youtux/cheat: Use entry_points instead of scripts in setup.py Improve setup.py description Exploit setuptools package_data to include cheats Use find_packages from setuptools to identify packages Use setuptools insted of distutils.
This commit is contained in:
65
cheat/app.py
Executable file
65
cheat/app.py
Executable file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""cheat
|
||||
|
||||
Usage:
|
||||
cheat <cheatsheet>
|
||||
cheat -e <cheatsheet>
|
||||
cheat -s <keyword>
|
||||
cheat -l
|
||||
cheat -d
|
||||
cheat -v
|
||||
|
||||
cheat allows you to create and view interactive cheatsheets on the
|
||||
command-line. It was designed to help remind *nix system
|
||||
administrators of options for commands that they use frequently,
|
||||
but not frequently enough to remember.
|
||||
|
||||
Examples:
|
||||
To look up 'tar':
|
||||
cheat tar
|
||||
|
||||
To create or edit the cheatsheet for 'foo':
|
||||
cheat -e foo
|
||||
|
||||
Options:
|
||||
-d --directories List directories on CHEATPATH
|
||||
-e --edit Edit cheatsheet
|
||||
-l --list List cheatsheets
|
||||
-s --search Search cheatsheets for <keyword>
|
||||
-v --version Print the version number
|
||||
"""
|
||||
|
||||
# require the dependencies
|
||||
import sheet
|
||||
import sheets
|
||||
from utils import *
|
||||
from docopt import docopt
|
||||
|
||||
|
||||
def main():
|
||||
# parse the command-line options
|
||||
options = docopt(__doc__, version='cheat 2.1.16')
|
||||
|
||||
# list directories
|
||||
if options['--directories']:
|
||||
print("\n".join(sheets.paths()))
|
||||
|
||||
# list cheatsheets
|
||||
elif options['--list']:
|
||||
print(sheets.list())
|
||||
|
||||
# create/edit cheatsheet
|
||||
elif options['--edit']:
|
||||
sheet.create_or_edit(options['<cheatsheet>'])
|
||||
|
||||
# search among the cheatsheets
|
||||
elif options['--search']:
|
||||
print(colorize(sheets.search(options['<keyword>'])))
|
||||
|
||||
# print the cheatsheet
|
||||
else:
|
||||
print(colorize(sheet.read(options['<cheatsheet>'])))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user