mirror of
https://github.com/cheat/cheat.git
synced 2025-09-03 18:48:29 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
afcaaafbe5 | |||
f128167311 | |||
74a91aa1d4 | |||
377da479e6 |
@ -38,7 +38,7 @@ from docopt import docopt
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# parse the command-line options
|
# parse the command-line options
|
||||||
options = docopt(__doc__, version='cheat 2.0.2')
|
options = docopt(__doc__, version='cheat 2.0.4')
|
||||||
|
|
||||||
# list directories
|
# list directories
|
||||||
if options['--directories']:
|
if options['--directories']:
|
||||||
|
@ -2,6 +2,12 @@ from cheat import cheatsheets
|
|||||||
from cheat.utils import *
|
from cheat.utils import *
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
# @kludge: it breaks the functional paradigm to a degree, but declaring this
|
||||||
|
# var here (versus within get()) gives us a "poor man's" memoization on the
|
||||||
|
# call to get(). This, in turn, spares us from having to call out to the
|
||||||
|
# filesystem more than once.
|
||||||
|
cheats = {}
|
||||||
|
|
||||||
|
|
||||||
def default_path():
|
def default_path():
|
||||||
""" Returns the default cheatsheet path """
|
""" Returns the default cheatsheet path """
|
||||||
@ -35,10 +41,15 @@ def default_path():
|
|||||||
return default_sheets_dir
|
return default_sheets_dir
|
||||||
|
|
||||||
|
|
||||||
# @todo: memoize result
|
|
||||||
def get():
|
def get():
|
||||||
""" Assembles a dictionary of cheatsheets as name => file-path """
|
""" Assembles a dictionary of cheatsheets as name => file-path """
|
||||||
cheats = {}
|
|
||||||
|
# if we've already reached out to the filesystem, just return the result
|
||||||
|
# from memory
|
||||||
|
if cheats:
|
||||||
|
return cheats
|
||||||
|
|
||||||
|
# otherwise, scan the filesystem
|
||||||
for cheat_dir in reversed(paths()):
|
for cheat_dir in reversed(paths()):
|
||||||
cheats.update(
|
cheats.update(
|
||||||
dict([
|
dict([
|
||||||
|
17
setup.py
17
setup.py
@ -1,9 +1,18 @@
|
|||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
data = [
|
||||||
|
('/usr/share/zsh/site-functions', ['cheat/autocompletion/_cheat.zsh']),
|
||||||
|
('/etc/bash_completion.d' , ['cheat/autocompletion/cheat.bash']),
|
||||||
|
('/usr/share/fish/completions' , ['cheat/autocompletion/cheat.fish'])
|
||||||
|
]
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
data = []
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'cheat',
|
name = 'cheat',
|
||||||
version = '2.0.2',
|
version = '2.0.4',
|
||||||
author = 'Chris Lane',
|
author = 'Chris Lane',
|
||||||
author_email = 'chris@chris-allen-lane.com',
|
author_email = 'chris@chris-allen-lane.com',
|
||||||
license = 'GPL3',
|
license = 'GPL3',
|
||||||
@ -21,11 +30,7 @@ setup(
|
|||||||
'cheat.cheatsheets': [f for f in os.listdir('cheat/cheatsheets') if '.' not in f]
|
'cheat.cheatsheets': [f for f in os.listdir('cheat/cheatsheets') if '.' not in f]
|
||||||
},
|
},
|
||||||
scripts = ['bin/cheat'],
|
scripts = ['bin/cheat'],
|
||||||
data_files = [
|
data_files = data,
|
||||||
('/usr/share/zsh/site-functions', ['cheat/autocompletion/_cheat.zsh']),
|
|
||||||
('/etc/bash_completion.d' , ['cheat/autocompletion/cheat.bash']),
|
|
||||||
('/usr/share/fish/completions' , ['cheat/autocompletion/cheat.fish'])
|
|
||||||
],
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'docopt >= 0.6.1',
|
'docopt >= 0.6.1',
|
||||||
'pygments >= 1.6.0',
|
'pygments >= 1.6.0',
|
||||||
|
Reference in New Issue
Block a user