mirror of
https://github.com/cheat/cheat.git
synced 2024-12-18 10:45:05 +01:00
Package with distutils
Created cheatsheets package to store the default sheets.
This commit is contained in:
parent
098384d341
commit
8dda6a9241
13
cheat
13
cheat
@ -1,18 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
from cheatsheets import cheat_dir
|
||||
|
||||
# assemble a keyphrase out of all params passed to the script
|
||||
keyphrase = ' '.join(sys.argv[1:])
|
||||
cheat_dir = os.path.expanduser('~') + '/.cheat/'
|
||||
|
||||
# verify that the ~/.cheat directory exists
|
||||
# verify that the cheat directory exists
|
||||
if not os.path.isdir(cheat_dir):
|
||||
print >> sys.stderr, 'The ~/.cheat directory does not exist.'
|
||||
print >> sys.stderr, 'The cheat directory does not exist.'
|
||||
exit()
|
||||
|
||||
# list the files in the ~/.cheat directory
|
||||
cheatsheets = os.listdir(cheat_dir)
|
||||
# list the files in the cheat directory
|
||||
cheatsheets = [f for f in os.listdir(cheat_dir) if '.' not in f]
|
||||
cheatsheets.sort()
|
||||
|
||||
# print help if requested
|
||||
@ -24,7 +24,8 @@ if keyphrase in ['', 'help', '--help', '-h']:
|
||||
|
||||
# print the cheatsheet if it exists
|
||||
if keyphrase in cheatsheets:
|
||||
with open (cheat_dir + keyphrase, 'r') as cheatsheet:
|
||||
cheatsheet_filename = os.path.join(cheat_dir, keyphrase)
|
||||
with open(cheatsheet_filename, 'r') as cheatsheet:
|
||||
print cheatsheet.read()
|
||||
|
||||
# if it does not, say so
|
||||
|
3
cheatsheets/__init__.py
Normal file
3
cheatsheets/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
import os
|
||||
|
||||
cheat_dir, __init = os.path.split(__file__)
|
16
setup.py
Normal file
16
setup.py
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from distutils.core import setup
|
||||
import os
|
||||
|
||||
setup(name='cheat',
|
||||
version='1.0',
|
||||
description='Create and view interactive cheatsheets on the command-line',
|
||||
author='Chris Lane',
|
||||
author_email='chris@chris-allen-lane.com',
|
||||
url='https://github.com/chrisallenlane/cheat',
|
||||
packages=['cheatsheets'],
|
||||
package_data={'cheatsheets': [f for f in os.listdir('cheatsheets')
|
||||
if '.' not in f]},
|
||||
scripts=['cheat']
|
||||
)
|
Loading…
Reference in New Issue
Block a user